:root {
    --primary-color: #000;
    --hover-bg: #f4f4f4;
    --border-radius: 6px;
    --card-height: auto;
    --meta-color: #888;
    --link-color: #2575fc;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #fff;
    color: #333;
    min-height: 100vh;
    position: relative;
    padding-bottom: 60px;
    overflow-x: hidden;
}

/* ==========================================================================
   页面标题
   ========================================================================== */
h1 {
    text-align: left;
    margin: 0 0 25px 0;
    color: #000;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

h1::after { display: none; }

/* ==========================================================================
   容器网格 - 布局调整
   ========================================================================== */
.book-grid {
    display: grid;
    /* 核心设定：最小列宽 240px，让卡片保持窄长精致，一行能显示更多 */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 20px; 
    padding: 0;
    max-width: 100%;
    margin: 0;
    position: relative;
}

/* 加载状态 */
.book-grid.loading {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-state { text-align: center; color: #666; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   Metacritic 风格卡片 (左图右文)
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.book-item {
    background-color: #f9f9f9;
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: row; /* 横向布局 */
    align-items: stretch;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid #eee;
    min-height: 120px;
    position: relative;
    animation: fadeIn 0.3s ease-out forwards;
}

.book-item:hover {
    background-color: #fff;
    border-color: #ccc;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    z-index: 2;
}

/* --- 左侧封面 --- */
.book-cover {
    width: 80px; /* 封面宽度缩小适配窄卡片 */
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: #eee;
    border-right: 1px solid #f0f0f0;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.book-item:hover .book-cover img {
    transform: scale(1.05);
}

/* --- 右侧信息 --- */
.book-info {
    flex-grow: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

/* 1. 头部：标题 + 元数据 */
.book-header {
    margin-bottom: 4px;
}

.book-item h2 {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: #000;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-item:hover h2 {
    text-decoration: underline;
}

.meta-line {
    font-size: 10px;
    color: var(--meta-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 2. 内容：简介 */
.book-body p {
    margin: 0 0 6px 0;
    color: #555;
    font-size: 12px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 3. 底部：评分 */
.book-footer {
    display: flex;
    align-items: center;
    margin-top: auto;
}

.meta-rating {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 1px 5px;
    border-radius: 4px;
}

.rating-score {
    font-weight: 800;
    font-size: 12px;
    color: #000;
    margin-right: 4px;
    line-height: 1;
}

.stars {
    color: #ffc107;
    font-size: 10px;
    letter-spacing: -1px;
}

.no-score {
    color: #999;
    font-size: 10px;
    background: transparent;
    border-color: transparent;
    padding-left: 0;
}

/* 隐藏旧的 UI 元素 */
.tags-display { display: none; }
.card-rating { display: none; }

/* ==========================================================================
   状态提示
   ========================================================================== */
.no-results, .error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    margin-top: 20px;
}

.no-results h3 { margin-bottom: 10px; color: #000; }
.error-message { background: #fff5f5; color: #c0392b; border: 1px solid #ffcccc; }

/* ==========================================================================
   分页样式 (修复纵向排列问题)
   ========================================================================== */
.pagination {
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.pagination-controls {
    display: inline-flex;
    align-items: center;
    gap: 12px; 
}

/* 通用按钮样式 */
.pagination button {
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
}

/* 上一页/下一页 按钮 */
#prev-page, #next-page {
    padding: 8px 16px;
}

/* 🔥 修复点：给页码容器添加 flex，强制横向排列 */
#page-numbers {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 数字页码按钮 */
#page-numbers button {
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination button:hover:not(:disabled) {
    background: #333;
    transform: translateY(-2px);
}

.pagination button:disabled {
    background: #ccc;
    cursor: default;
    transform: none;
}

.pagination button.active {
    background: #2575fc; 
}

/* 跳转区域 */
.pagination-jump {
    display: flex;
    gap: 8px;
    align-items: center;
}

#jump-to-page {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 50px;
    text-align: center;
}

#jump-button {
    padding: 8px 12px;
}

.page-indicator {
    font-size: 13px;
    color: #666;
    margin-top: 10px;
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

/* ==========================================================================
   响应式设计
   ========================================================================== */

@media (max-width: 600px) {
    .book-grid {
        grid-template-columns: 1fr; /* 手机端单列 */
        gap: 15px;
    }

    .book-item {
        min-height: 110px;
    }

    .book-cover {
        width: 80px; 
    }

    .book-info {
        padding: 8px 10px;
    }
    
    /* 移动端分页间距微调 */
    .pagination-controls {
        gap: 8px;
    }
    #page-numbers button {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}