body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding-top: 70px; /* 为固定头部留出空间 */
    background-color: #f4f4f4;
    color: #333;
    line-height: 1.6; /* 增加行高，提高可读性 */
}

header {
    background-color: #007bff;
    color: white;
    padding: 0.8rem 20px; /* 调整内边距 */
    position: fixed; /* 固定在顶部 */
    top: 0;
    width: 100%;
    z-index: 1000; /* 确保在其他内容之上 */
    display: flex; /* 使用 Flexbox 布局 */
    align-items: center; /* 垂直居中 */
    justify-content: space-between; /* 元素之间留有空间 */
    box-sizing: border-box; /* 包含 padding 和 border 在宽度内 */
    height: 70px; /* 固定高度 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* 添加阴影 */
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
}

.header-center {
    flex-grow: 1; /* 允许标题占据可用空间 */
    justify-content: center; /* 标题居中 */
    text-align: center; /* 确保标题文本居中 */
}

.header-title {
    margin: 0;
    font-size: 1.8rem; /* 增大标题字体 */
    white-space: nowrap; /* 防止标题换行 */
    overflow: hidden; /* 隐藏溢出部分 */
    text-overflow: ellipsis; /* 显示省略号 */
    max-width: 100%; /* 限制标题最大宽度 */
}

.home-link {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    white-space: nowrap; /* 防止链接文本换行 */
}

.home-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.home-logo-link {
    display: flex;
    align-items: center;
    margin-right: 15px; /* logo 和标题之间的间距 */
}

.home-logo {
    height: 40px; /* logo 高度 */
    width: auto;
    vertical-align: middle; /* 垂直对齐 */
}

#search-input {
    width: 250px; /* 调整搜索框宽度 */
    padding: 8px 12px; /* 调整触摸区域 */
    border: none;
    border-radius: 5px;
    font-size: 1rem; /* 调整字体 */
    margin-top: 0; /* 移除顶部外边距 */
}

#category-nav {
    display: flex;
    flex-wrap: wrap; /* 允许换行 */
    justify-content: center;
    padding: 10px 0;
    background-color: #e9ecef;
    margin-bottom: 20px;
}

.category-link {
    display: block; /* 使整个链接区域可点击 */
    padding: 10px 15px; /* 增加触摸区域 */
    margin: 5px; /* 增加间距 */
    background-color: #f8f9fa;
    color: #007bff;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    font-size: 1rem; /* 调整字体大小 */
}

.category-link:hover {
    background-color: #e2e6ea;
}

main {
    max-width: 960px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 声明部分的样式 */
#statement-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
    text-align: center; /* 文本居中 */
}

#statement-section h2 {
    color: #dc3545; /* 警告色 */
    margin-top: 0;
    font-size: 1.3rem;
}

#statement-section p {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 10px;
    text-align: left; /* 段落左对齐 */
}

#agree-button {
    display: block; /* 块级元素，占据整行 */
    width: fit-content; /* 宽度适应内容 */
    margin: 20px auto; /* 居中显示 */
    padding: 15px 30px; /* 增加触摸区域 */
    font-size: 1.2rem; /* 增大字体 */
    font-weight: bold;
    color: white;
    background-color: #28a745; /* 绿色按钮 */
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    min-width: 200px; /* 最小宽度 */
    min-height: 50px; /* 最小高度 */
}

#agree-button:hover {
    background-color: #218838; /* 悬停颜色 */
    transform: translateY(-1px); /* 轻微上浮 */
}

#agree-button:active {
    background-color: #1e7e34; /* 点击颜色 */
    transform: translateY(0);
}

#resource-list {
    list-style: none;
    padding: 0;
}

#resource-list li {
    background-color: white;
    margin-bottom: 10px;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column; /* 手机上垂直布局 */
    justify-content: space-between;
    align-items: flex-start; /* 左对齐 */
    cursor: pointer; /* 指示可点击 */
    transition: all 0.3s ease; /* 添加过渡效果 */
}

#resource-list li.resource-card:hover {
    background-color: #e9f2ff; /* 悬停背景色 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* 悬停阴影效果 */
    transform: translateY(-2px); /* 轻微上浮效果 */
}

#resource-list li div {
    margin-bottom: 10px; /* 增加信息与链接的间距 */
}

#resource-list li strong {
    font-size: 1.1rem; /* 增大资源名称字体 */
}

#resource-list li small {
    font-size: 0.9rem; /* 调整小字体 */
}

#pagination-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

#pagination-controls button {
    margin: 5px; /* 调整间距 */
    padding: 10px 15px; /* 增加触摸区域 */
    border: 1px solid #007bff;
    border-radius: 5px;
    background-color: white;
    color: #007bff;
    cursor: pointer;
    font-size: 1rem;
    min-width: 44px; /* 最小触摸尺寸 */
    min-height: 44px; /* 最小触摸尺寸 */
}

#pagination-controls button:hover:not(.active) {
    background-color: #e9f2ff;
}

#pagination-controls button.active {
    background-color: #007bff;
    color: white;
}

#pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    margin: 5px; /* 调整间距 */
    padding: 10px 0;
    font-size: 1rem;
}

footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
    background-color: #333;
    color: white;
    font-size: 0.9rem;
}

/* 针对所有类别页面的样式 */
#categories-list ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#categories-list li {
    margin: 8px; /* 增加间距 */
}

#categories-list li a {
    display: block;
    padding: 12px 18px; /* 增加触摸区域 */
    background-color: #f8f9fa;
    color: #007bff;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    font-size: 1.1rem; /* 增大字体 */
    min-width: 80px; /* 确保最小宽度 */
    text-align: center; /* 文本居中 */
}

#categories-list li a:hover {
    background-color: #e2e6ea;
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding-top: 120px; /* 手机上为两行头部留出空间 */
    }

    header {
        flex-wrap: wrap; /* 允许头部内容换行 */
        height: auto; /* 高度自适应 */
        padding: 0.5rem 15px;
    }

    .header-left, .header-center, .header-right {
        width: 100%; /* 手机上占据整行 */
        justify-content: center; /* 居中显示 */
        margin-bottom: 10px; /* 元素之间增加间距 */
    }

    .header-left {
        justify-content: flex-start; /* 左侧元素左对齐 */
        margin-bottom: 0;
    }

    .home-logo-link {
        margin-right: 10px;
    }

    .header-title {
        font-size: 1.5rem;
        text-align: center;
    }

    #search-input {
        width: 90%; /* 手机上搜索框宽度 */
        font-size: 0.9rem;
        padding: 6px 10px;
        margin-top: 0;
    }

    #statement-section h2 {
        font-size: 1.1rem;
    }

    #statement-section p {
        font-size: 0.85rem;
    }

    #agree-button {
        padding: 12px 25px;
        font-size: 1rem;
        min-width: 160px;
        min-height: 45px;
    }

    .category-link {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    #resource-list li {
        padding: 10px;
    }

    #resource-list li strong {
        font-size: 1rem;
    }

    #resource-list li small {
        font-size: 0.8rem;
    }

    /* 移除对 resource-list li a 的手机端样式，因为现在整个卡片可点击 */

    #pagination-controls button {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 40px;
        min-height: 40px;
    }

    .pagination-ellipsis {
        font-size: 0.9rem;
    }

    #categories-list li a {
        font-size: 1rem; /* 手机上字体大小 */
        padding: 10px 15px; /* 手机上触摸区域 */
        min-width: 70px; /* 手机上最小宽度 */
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 100px; /* 进一步调整小屏幕的顶部内边距 */
    }

    header {
        padding: 0.5rem 10px;
    }

    .header-title {
        font-size: 1.3rem; /* 进一步缩小标题字体 */
    }

    .home-link {
        font-size: 1rem;
        padding: 3px 8px;
    }

    .home-logo {
        height: 35px; /* 缩小 logo */
    }

    #search-input {
        width: 95%; /* 搜索框宽度更大 */
        font-size: 0.85rem;
        padding: 5px 8px;
    }

    .category-link {
        font-size: 0.85rem;
        padding: 6px 10px;
        margin: 3px;
    }

    main {
        margin: 10px auto;
        padding: 0 10px;
    }

    #statement-section {
        padding: 15px;
    }

    #statement-section h2 {
        font-size: 1rem;
    }

    #statement-section p {
        font-size: 0.8rem;
    }

    #agree-button {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-width: 140px;
        min-height: 40px;
    }

    #resource-list li {
        padding: 8px;
    }

    #resource-list li strong {
        font-size: 0.9rem;
    }

    #resource-list li small {
        font-size: 0.75rem;
    }

    #pagination-controls button {
        padding: 6px 10px;
        font-size: 0.85rem;
        min-width: 36px;
        min-height: 36px;
    }

    #categories-list li a {
        font-size: 0.9rem;
        padding: 8px 12px;
        min-width: 60px;
    }
}

@media (max-width: 320px) {
    body {
        padding-top: 90px; /* 针对 320px 屏幕进一步调整顶部内边距 */
    }

    header {
        padding: 0.4rem 8px;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .home-link {
        font-size: 0.9rem;
        padding: 2px 6px;
    }

    .home-logo {
        height: 30px;
    }

    #search-input {
        width: 98%;
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    .category-link {
        font-size: 0.8rem;
        padding: 5px 8px;
        margin: 2px;
    }

    main {
        margin: 5px auto;
        padding: 0 8px;
    }

    #statement-section {
        padding: 10px;
    }

    #statement-section h2 {
        font-size: 0.9rem;
    }

    #statement-section p {
        font-size: 0.75rem;
    }

    #agree-button {
        padding: 8px 15px;
        font-size: 0.8rem;
        min-width: 120px;
        min-height: 35px;
    }

    #resource-list li {
        padding: 6px;
    }

    #resource-list li strong {
        font-size: 0.85rem;
    }

    #resource-list li small {
        font-size: 0.7rem;
    }

    #pagination-controls button {
        padding: 5px 8px;
        font-size: 0.8rem;
        min-width: 32px;
        min-height: 32px;
    }

    #categories-list li a {
        font-size: 0.85rem;
        padding: 6px 10px;
        min-width: 50px;
    }
}
/* Loading Overlay Styles */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #007bff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay p {
    font-size: 1.2rem;
    color: #555;
}