/* ========== Reset & Variables ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --bg: #f5f5f5;
    --card-bg: #fff;
    --text: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #e0e0e0;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 1200px;
    --header-height: 60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; }
img { max-width: 100%; display: block; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* ========== Header ========== */
.header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 500px;
    margin-left: 24px;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 8px 36px 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s;
    background: #fafafa;
}

.search-box input:focus {
    border-color: var(--primary);
    background: #fff;
}

.btn-search {
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .2s;
}

.btn-search:hover { background: var(--primary-dark); }
.btn-back {
    padding: 6px 16px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: .9rem;
    color: #555;
    transition: background .2s;
}
.btn-back:hover { background: #e0e0e0; }

/* Search Suggestions Dropdown */
.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
}

.search-suggestions.active { display: block; }

.search-suggestions .suggest-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: .9rem;
    border-bottom: 1px solid #f5f5f5;
    transition: background .15s;
}

.search-suggestions .suggest-item:hover { background: #fdf2f2; color: var(--primary); }

/* ========== Hero ========== */
.hero {
    text-align: center;
    padding: 48px 0 36px;
    background: linear-gradient(135deg, #fdf2f2 0%, #fff5f5 50%, #fff 100%);
    border-radius: var(--radius);
    margin-top: 20px;
}

.hero h1 { font-size: 2rem; color: var(--primary); margin-bottom: 8px; }
.hero p { color: var(--text-secondary); font-size: 1rem; margin-bottom: 24px; }

.hero-search {
    display: flex;
    max-width: 480px;
    margin: 0 auto;
    gap: 0;
}

.hero-search input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--primary);
    border-right: none;
    border-radius: 28px 0 0 28px;
    font-size: 1rem;
    outline: none;
}

.hero-search button {
    padding: 12px 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 0 28px 28px 0;
    font-size: 1rem;
    font-weight: 600;
    transition: background .2s;
}
.hero-search button:hover { background: var(--primary-dark); }

/* ========== Section ========== */
.section { margin: 28px 0; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 { font-size: 1.25rem; color: var(--text); }

/* ========== Tab Switch ========== */
.tab-switch {
    display: flex;
    gap: 4px;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 3px;
}

.tab-switch .tab {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: .85rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all .2s;
}

.tab-switch .tab.active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* ========== Hot Tags ========== */
.hot-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hot-tag {
    padding: 6px 16px;
    background: #fff;
    border: 1px solid #ffe0e0;
    border-radius: 20px;
    font-size: .85rem;
    color: var(--primary);
    cursor: pointer;
    transition: all .2s;
}

.hot-tag:hover { background: #fdf2f2; border-color: var(--primary); transform: translateY(-1px); }

/* ========== Book Grid ========== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.book-card .cover {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    background: linear-gradient(135deg, #f8d4d4, #fdf2f2);
}

.book-card .info {
    padding: 10px 12px;
}

.book-card .title {
    font-size: .9rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.6em;
}

.book-card .author {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.book-card .meta {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* No cover placeholder */
.cover-placeholder {
    width: 100%;
    aspect-ratio: 3/4;
    background: linear-gradient(135deg, #ffe0e0, #fff5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #d0a0a0;
}

/* ========== Rank List ========== */
.rank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    cursor: pointer;
    transition: background .2s;
}

.rank-item:hover { background: #fdf2f2; }

.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.rank-num.top-1 { background: #e74c3c; color: #fff; }
.rank-num.top-2 { background: #e67e22; color: #fff; }
.rank-num.top-3 { background: #f39c12; color: #fff; }

.rank-cover {
    width: 48px;
    height: 64px;
    border-radius: 4px;
    object-fit: cover;
    background: #f5f5f5;
    flex-shrink: 0;
}

.rank-info { flex: 1; min-width: 0; }

.rank-title {
    font-size: .9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-author { font-size: .75rem; color: var(--text-muted); }
.rank-desc { font-size: .7rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== Book Detail ========== */
.book-info {
    display: flex;
    gap: 20px;
    padding: 24px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.book-info .detail-cover {
    width: 140px;
    min-width: 140px;
    height: 190px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: linear-gradient(135deg, #f8d4d4, #fdf2f2);
    flex-shrink: 0;
}

.book-detail-text { flex: 1; min-width: 0; }

.book-detail-text h1 {
    font-size: 1.3rem;
    line-height: 1.3;
    margin-bottom: 8px;
}

.book-detail-text .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.book-detail-text .desc {
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.btn-primary, .btn-outline {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 600;
    transition: all .2s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: #fdf2f2; }

/* ========== Chapter List ========== */
.chapter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}

.chapter-item {
    padding: 10px 14px;
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .88rem;
    transition: all .2s;
    border: 1px solid #f0f0f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-item:hover {
    border-color: #ffcccc;
    background: #fffafa;
    color: var(--primary);
}

.chapter-item .chap-vip {
    font-size: .7rem;
    color: #f39c12;
    margin-left: 6px;
}

/* ========== Load More ========== */
.load-more-wrap {
    text-align: center;
    margin-top: 16px;
}

.btn-load-more {
    padding: 10px 32px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}

.btn-load-more:hover {
    background: #fdf2f2;
    border-color: #ffcccc;
    color: var(--primary);
}

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: .8rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.footer a { color: var(--primary); }

/* ========== Back to Top ========== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(231,76,60,.4);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity .3s;
}

.back-to-top.show { display: flex; }

/* ========== Skeleton Loading ========== */
.skeleton, .skeleton-box {
    animation: shimmer 1.5s infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-tag {
    width: 80px; height: 32px; border-radius: 16px; display: inline-block;
    animation: shimmer 1.5s infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

.skeleton-cover {
    width: 140px; min-width: 140px; height: 190px; border-radius: 8px;
    animation: shimmer 1.5s infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }

.skeleton-line {
    height: 16px; border-radius: 4px;
    animation: shimmer 1.5s infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }

/* ========== No Results ========== */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .hero { padding: 32px 0 24px; }
    .hero h1 { font-size: 1.5rem; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .book-info { flex-direction: column; align-items: center; text-align: center; }
    .book-info .detail-cover { width: 120px; min-width: 120px; height: 160px; }
    .book-actions { justify-content: center; }
    .chapter-list { grid-template-columns: 1fr; }
    .rank-item { padding: 10px 12px; }
    .header-search { display: none; }
}

/* ========== Highlight <em> ========== */
em.highlight {
    color: #e74c3c;
    font-style: normal;
    font-weight: 700;
}

@media (max-width: 480px) {
    .book-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .hero-search input { padding: 10px 14px; font-size: .9rem; }
    .hero-search button { padding: 10px 16px; font-size: .9rem; }
}
