* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 防止移动端横向拖动 */
@media (max-width: 768px) {
    /* 确保所有元素宽度不超过视口 */
    * {
        max-width: 100% !important;
        /* 防止长单词或URL导致溢出 */
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    /* 确保根元素不会横向滚动 */
    html, body {
        overflow-x: hidden !important;
        /* 只允许垂直触摸滑动 */
        touch-action: pan-y;
    }
    
    /* 确保主要容器不会超出视口 */
    .nav-container,
    .header-content,
    main,
    .footer-content {
        width: 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }
}

:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --dark-bg: #1a1a2e;
    --card-bg: #16213e;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --accent-gold: #ffd93d;
    --retro-purple: #6c5ce7;
    --retro-green: #00d2d3;
}

.pixel-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, var(--text-primary) 2px, var(--text-primary) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, var(--text-primary) 2px, var(--text-primary) 4px);
    pointer-events: none;
    z-index: 0;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.floating-pixels {
    position: fixed;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.pixel {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    opacity: 0.3;
    animation: float 6s infinite ease-in-out;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--accent-gold);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.header-content {
    width: 100%;
    margin: 0 auto;
    padding: 0.2rem 1rem;
    display: flex;
    flex-direction: column;
    position: relative;
    gap: 4px;
}

/* 页眉自定义背景图片层 */
.header-bg-image-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    pointer-events: none;
}

.header-content > .header-row {
    position: relative;
    z-index: 1;
}

/* ===== 页眉预设动态背景（GIF图片层） ===== */
.header-bg-preset-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.header-bg-preset-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.header-row-top {
    justify-content: space-between;
    min-height: 40px;
    gap: 15px;
}

.header-row-bottom {
    min-height: 36px;
}

.logo-section {
    text-align: left;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-title {
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    font-weight: bold;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-gold), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin: 0;
    letter-spacing: 1px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-title img {
    width: 36px !important;
    height: 36px !important;
    border-radius: 6px;
}

.logo-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.logo-subtitle {
    font-size: 10px;
    color: var(--text-secondary);
    margin: 0;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
    opacity: 0.85;
}

/* 中等屏幕及以下隐藏副标题（避免挡住搜索条），手机端同样隐藏 */
@media (max-width: 900px) {
    .logo-subtitle { display: none; }
}

/* 整合导航区域 */
.topbar-nav-area {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

.topbar-search-area {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 0;
}

.topbar-search-area input {
    padding: 4px 10px;
    border: 1px solid var(--retro-purple);
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 12px;
    width: 150px;
    height: 28px;
}

.search-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    color: var(--text-primary);
    border-radius: 4px;
    transition: background 0.2s;
}

.search-icon-btn:hover {
    background: rgba(255, 215, 61, 0.15);
}

.search-clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.search-clear-btn:hover {
    color: var(--accent-gold);
    background: rgba(255, 215, 61, 0.15);
}

.topbar-right-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* 用户登录图标按钮 */
.user-login-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.user-login-btn:hover {
    background: var(--primary-color);
    color: white;
}

.user-avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.user-avatar-btn:hover {
    opacity: 0.85;
}

/* 登录弹出面板 */
.login-popup {
    display: none;
    position: absolute;
    top: 100%;
    right: 10px;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 200;
    min-width: 160px;
    gap: 8px;
    flex-direction: column;
}

.login-popup-btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.login-popup-btn:hover {
    opacity: 0.88;
}

.login-popup-login {
    background: var(--primary-color);
    color: white;
}

.login-popup-register {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* 导航按钮容器 - 连成一片 */
.nav-buttons {
    display: flex;
    gap: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow: visible;
    scrollbar-width: none;
}
.nav-buttons::-webkit-scrollbar { display: none; }

/* 导航按钮 - 连成一片样式 */
.nav-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 0;
    text-align: center;
}
.nav-btn:last-child { border-right: none; }

.nav-btn:hover {
    color: var(--accent-gold);
    background: rgba(255, 215, 61, 0.08);
}

.nav-btn.active {
    color: var(--accent-gold);
    background: rgba(255, 215, 61, 0.12);
}

.nav-dropdown-arrow {
    font-size: 15px;
    margin-left: 4px;
    color: var(--text-secondary);
    display: inline-block;
    vertical-align: middle;
}

.nav-dropdown:hover > .nav-btn > .nav-dropdown-arrow {
    color: var(--accent-gold);
}

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

.nav-dropdown-content {
    display: none;
    position: absolute;
    background: rgba(22, 33, 62, 0.98);
    min-width: max-content;
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    z-index: 200;
    border-radius: 0 0 6px 6px;
    border: 1px solid rgba(255, 215, 61, 0.2);
    border-top: none;
    padding: 4px 0;
    top: 100%;
    left: 0;
    margin-top: 0;
}

.nav-dropdown:hover > .nav-dropdown-content {
    display: block;
}

.nav-dropdown-content .nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 20px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
}
.nav-dropdown-content .nav-btn:last-child { border-bottom: none; }

.nav-dropdown-content .nav-dropdown {
    display: block;
}

.nav-dropdown-content .nav-dropdown .nav-dropdown-content {
    left: 100%;
    top: 0;
    margin-top: 0;
    border-top: 1px solid rgba(255, 215, 61, 0.2);
    border-left: none;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 100;
    width: 40px;
    height: 40px;
    align-items: center;
}

.menu-toggle .bar {
    width: 24px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: block;
}

.menu-toggle.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}
.menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* 手机端汉堡菜单面板 */
.mobile-menu-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    max-width: 280px;
    height: 100vh;
    background: rgba(22, 33, 62, 0.98);
    backdrop-filter: blur(10px);
    z-index: 999;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-menu-panel.active {
    transform: translateX(0);
}

.mobile-menu-content {
    padding: 15px;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--accent-gold);
    font-size: 16px;
    font-weight: bold;
}

.mobile-nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-nav-buttons .nav-btn {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: none;
    font-size: 14px;
}

.mobile-nav-buttons .nav-dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 15px;
    background: rgba(0, 0, 0, 0.2);
}

.mobile-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 15px 0;
}

.mobile-login-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

main {
    position: relative;
    z-index: 10;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

@media (max-width: 768px) {
    main {
        padding: 1rem 0.5rem;
    }
}

.section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: 1rem;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-secondary);
}

.era-section {
    margin-bottom: 4rem;
}

.era-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--retro-purple);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.era-icon {
    font-size: 2rem;
}

.console-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.console-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(15, 52, 96, 0.8) 100%);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.console-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(78, 205, 196, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.console-card:hover::before {
    transform: translateX(100%);
}

.console-card:hover {
    border-color: var(--secondary-color);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 30px rgba(78, 205, 196, 0.3);
}

.console-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.console-icon {
    font-size: 2.5rem;
    min-width: 60px;
    text-align: center;
}

.console-info {
    flex: 1;
}

.console-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.console-fullname {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.console-details {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    color: var(--secondary-color);
    font-weight: bold;
}

.console-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid var(--primary-color);
    border-radius: 20px;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    color: var(--primary-color);
}

/* 文章卡片样式 */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .articles-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 1024px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* 超小屏幕设备 */
@media (max-width: 480px) {
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* 全局网格容器样式 - 确保文章卡片从左往右排列 */
.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    grid-template-rows: auto;
    width: 100%;
    max-width: 100%;
}

/* 响应式设计 */
@media (min-width: 1400px) {
    .grid-container {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1200px) {
    .grid-container {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1000px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 800px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* 网格容器子元素样式 */
.grid-container > div {
    transition: all 0.3s ease;
    width: 100%;
}

.grid-container > div:hover {
    border: 2px solid var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* ====== 首页叶子分类分组容器样式 ====== */
.home-categories-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 20px;
    box-sizing: border-box;
    position: relative;
}

.categories-bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0;
}
.categories-bg-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.home-categories-container > .home-category-section {
    position: relative;
    z-index: 1;
}

/* 主内容区背景层 */
.main-bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.main-bg-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#mainContent {
    position: relative;
    z-index: 1;
}

.home-category-section {
    margin-bottom: 40px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.home-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    flex-wrap: wrap;
    gap: 10px;
}

.home-category-title {
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    color: var(--text-primary, #fff);
    display: flex;
    align-items: center;
    gap: 10px;
}

.home-category-icon {
    font-size: 28px;
}

.home-category-more {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.home-category-more:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
}

/* 一排文章卡片容器 - 严格一排布局，按屏幕宽度自适应列数 */
.home-category-row {
    display: grid !important;
    gap: 16px;
    width: 100%;
    align-items: stretch;
    grid-auto-rows: 1fr;
}

/* 默认（桌面，中等分辨率）：一排 4 个 */
.home-category-row {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

/* 超大桌面（>=1600px）：一排 6 个 */
@media (min-width: 1600px) {
    .home-category-row {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    }
}

/* 大桌面（1280-1599px）：一排 5 个 */
@media (min-width: 1280px) and (max-width: 1599px) {
    .home-category-row {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}

/* 普通桌面（1100-1279px）：一排 4 个 */
@media (min-width: 1100px) and (max-width: 1279px) {
    .home-category-row {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* 平板（850-1099px）：一排 3 个 */
@media (max-width: 1099px) {
    .home-category-row {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 12px;
    }
}

/* 手机（<=550px）：一排 2 个 */
@media (max-width: 550px) {
    .home-category-row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
    }
}

/* 首页文章卡片 */
.home-article-card {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    height: 100%;
}

.home-article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.35);
    border: 2px solid var(--primary-color, #667eea);
}

.home-article-img-wrap {
    width: 100%;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: transparent;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-article-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s ease;
    background: transparent;
}

.home-article-card:hover .home-article-img-wrap img {
    transform: scale(1.05);
}

.home-article-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.home-article-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color, #667eea);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
    word-break: break-word;
}

.home-article-btn {
    padding: 5px 10px;
    background: var(--primary-color, #667eea);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s;
    align-self: flex-start;
    flex-shrink: 0;
}

.home-article-btn:hover {
    background: var(--accent-gold, #ffd700);
    color: #000;
}

.home-article-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.article-tags {
    padding: 6px 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}

.article-tag {
    display: inline-block;
    padding: 2px 7px;
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-color, #667eea);
    border-radius: 10px;
    font-size: 10px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-status-badge {
    padding: 4px;
    color: white;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
}

.home-search-info {
    margin: 10px 0 20px;
    padding: 10px 18px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    border-left: 4px solid var(--accent-gold);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    color: var(--accent-gold);
    font-size: 14px;
}

.home-article-tags {
    padding: 6px 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}

.home-article-tag {
    display: inline-block;
    padding: 2px 7px;
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-color, #667eea);
    border-radius: 10px;
    font-size: 10px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-article-category-badge {
    padding: 4px 8px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 4px;
    display: inline-block;
}

/* ====== 首页叶子分类容器样式结束 ====== */

.article-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary-color);
    box-shadow: 0 10px 30px rgba(78, 205, 196, 0.3);
}

.article-image {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 确保无论列数如何变化，图片大小保持不变且不超出原图尺寸 */
.article-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.article-card:hover .article-image img {
    transform: scale(1.05);
}

.article-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

/* 超小屏幕设备 */
@media (max-width: 480px) {
    .articles-grid {
        gap: 1rem;
    }
    
    .article-body {
        padding: 1rem;
    }
    
    .article-title {
        font-size: 1.1rem;
    }
}

.article-title {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.article-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.read-more {
    color: var(--secondary-color);
    font-weight: bold;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    /* 移除overflow-y: auto，让滚动发生在页面上 */
    /* 优化：使用flex布局居中显示 */
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.modal-content {
    background: linear-gradient(135deg, var(--card-bg) 0%, #0f3460 100%);
    margin: 0;
    /* 优化：增加内边距 */
    padding: 2.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    animation: slideDown 0.3s ease;
    /* 优化：确保表单弹窗有合适的最大宽度 */
    width: 100%;
    max-width: 100%;
    /* 添加最大高度和滚动 */
    max-height: 100vh;
    height: 100vh;
    overflow-y: auto;
    /* 确保滚动条样式一致 */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255, 255, 255, 0.1);
    /* 确保内容不会覆盖关闭按钮 */
    margin-top: 0;
}

/* 文章详情模态框特殊样式 */
#articleModal .modal-content {
    max-width: 100%;
    width: 100%;
    margin-top: 0;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 1.5rem;
}

/* 图片点击放大样式 */
.article-detail-content img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.article-detail-content img:hover {
    transform: scale(1.02);
}

/* 防止表格导致横向溢出 */
table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
    border-collapse: collapse;
}

/* 防止iframe导致横向溢出 */
iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 防止视频元素导致横向溢出 */
video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 防止代码块导致横向溢出 */
pre, code {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 图片查看器模态框 */
#imageViewerModal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    overflow-y: auto;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#imageViewerModal .modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 90%;
    max-height: 90%;
}

#imageViewerModal img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    margin: 0 auto;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
}

/* 按钮通用样式 */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary-color), var(--retro-green));
    color: var(--dark-bg);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.btn-success:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--retro-purple));
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* 模态框标题样式优化 */
.modal-content h2 {
    margin: 0 0 2rem 0;
    text-align: center;
    font-size: 1.8rem;
    color: var(--text-primary);
    font-weight: bold;
}

/* 注册按钮样式优化 */
.modal-content .btn {
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    font-size: 1.1rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: var(--text-secondary);
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    background: rgba(15, 52, 96, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    /* 确保按钮始终可见 */
    opacity: 1 !important;
    visibility: visible !important;
}

.close:hover {
    color: var(--primary-color);
    background: rgba(255, 107, 107, 0.1);
    transform: rotate(90deg);
}

.article-detail-header {
    padding: 2rem;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.article-detail-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 1rem;
    color: var(--accent-gold);
}

.article-detail-meta {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.article-detail-meta a {
    color: var(--secondary-color);
    text-decoration: none;
}

.article-detail {
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.article-detail-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--retro-purple);
}

.article-detail-header h1 {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 15px;
    line-height: 1.2;
}

.article-detail-meta {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.article-detail-meta a {
    color: var(--accent-gold);
    text-decoration: none;
    transition: color 0.3s ease;
}

.article-detail-meta a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.article-detail-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin: 30px 0;
}

.article-detail-content p {
    margin-bottom: 20px;
}

.article-detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
    margin: 20px 0;
}

.article-detail-content img:hover {
    transform: scale(1.02);
}

.article-detail-content h1,
.article-detail-content h2,
.article-detail-content h3 {
    margin: 1.5rem 0 1rem;
    color: var(--accent-gold);
}

.article-detail-content a {
    color: var(--secondary-color);
    text-decoration: none;
}

.article-detail-content a:hover {
    text-decoration: underline;
}

footer {
    position: relative;
    z-index: 10;
    background: rgba(22, 33, 62, 0.95);
    border-top: 3px solid var(--accent-gold);
    padding: 2rem 1rem;
    text-align: center;
    margin-top: 4rem;
}

.footer-content {
    width: 100%;
    margin: 0 auto;
}

.footer-quote {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
}

.footer-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
}

.loading {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 积分充值弹窗样式 */
#pointsPackages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.points-package {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.points-package:hover {
    border-color: var(--accent-gold);
    background: rgba(255, 217, 61, 0.1);
    transform: translateY(-2px);
}

.points-package.selected {
    border-color: var(--accent-gold);
    background: rgba(255, 217, 61, 0.2);
    box-shadow: 0 0 0 3px rgba(255, 217, 61, 0.3);
}

.points-package h3 {
    margin: 0 0 0.5rem 0;
    color: var(--accent-gold);
    font-size: 1.2rem;
}

.points-package p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.points-package .price {
    margin-top: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        padding: 1.5rem 1rem;
    }

    .hero-quote {
        padding: 1rem;
        margin: 1rem;
    }

    .articles-grid {
        gap: 1rem;
    }

    .nav-container {
        gap: 0.5rem;
    }

    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .era-title {
        font-size: 1.3rem;
    }

    .modal-content {
        margin: 0;
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        padding: 0.5rem;
        border-radius: 0;
    }

    .article-detail-header,
    .article-detail-content {
        padding: 0.5rem;
    }

    #pointsPackages {
        grid-template-columns: 1fr;
    }
}

/* ==================== 新文章页面布局样式 ==================== */
.article-new-layout {
    max-width: 1200px;
    margin: 0 auto;
}

/* 名字区域：桌面端显示右栏中，手机端显示最上面 */
.article-new-layout .article-title-mobile { display: none; }
.article-new-layout .article-title-desktop { display: block; }

.article-new-layout img {
    transition: transform 0.2s ease;
}

.article-new-layout img:hover {
    transform: scale(1.03);
}

.article-new-layout table {
    border-collapse: collapse;
}

.article-new-layout table td:hover {
    background: rgba(102, 126, 234, 0.05);
}

.article-new-layout h3 {
    transition: color 0.2s ease;
}

/* 列表框双模式控制 */
/* 电脑端默认：transposed模式显示，normal模式隐藏 */
.article-new-layout .grid-table-normal { display: none !important; }
.article-new-layout .grid-table-transposed { display: block !important; }

/* 列表框图片始终纵向排列（单元格内多张图片上下排列） */
.article-new-layout .grid-cell-images {
    flex-direction: column;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .article-new-layout .article-title-mobile { display: block !important; }
    .article-new-layout .article-title-desktop { display: none !important; }
    .article-new-layout > div:nth-child(2) {
        flex-direction: column !important;
    }
    .article-new-layout > div:nth-child(2) > div {
        flex: 1 1 100% !important;
        min-width: 100% !important;
    }
    .article-new-layout {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .article-new-layout table {
        font-size: 11px;
    }

    /* 手机端默认：normal模式显示，transposed模式隐藏 */
    .article-new-layout .grid-table-normal { display: block !important; }
    .article-new-layout .grid-table-transposed { display: none !important; }
}

/* 切换按钮：电脑端切换后显示normal */
.article-new-layout .grid-mode-toggled .grid-table-normal { display: block !important; }
.article-new-layout .grid-mode-toggled .grid-table-transposed { display: none !important; }

/* 手机端切换后显示transposed */
@media (max-width: 768px) {
    .article-new-layout .grid-mode-toggled .grid-table-normal { display: none !important; }
    .article-new-layout .grid-mode-toggled .grid-table-transposed { display: block !important; }
}

/* ==================== 中等屏幕 ==================== */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .topbar-search-area input {
        width: 120px;
    }
}

/* ==================== 手机端响应式 ==================== */
@media (max-width: 768px) {
    .header-content {
        padding: 0.3rem 0.8rem;
        gap: 4px;
    }
    .header-row-top {
        min-height: 36px;
    }
    .header-row-bottom {
        display: none;
    }
    .logo-title {
        font-size: 1rem;
    }
    .logo-title img {
        width: 28px !important;
        height: 28px !important;
    }
    .topbar-search-area input {
        width: 80px;
        font-size: 11px;
    }

    .menu-toggle {
        display: flex !important;
    }
    #loginButtons {
        display: none !important;
    }
    #userInfo {
        display: none !important;
    }
    .mobile-menu-panel {
        display: block;
    }
}
