/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f5f5f5;
    --bg-card: #ffffff;
    --accent: #e23a3a;
    --accent-light: #ff6b6b;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e8e8e8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 750px;
    margin: 0 auto;
    background: var(--bg-primary);
    min-height: 100vh;
    padding-bottom: 60px;
}

/* 顶部导航 */
.header {
    background: var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 15px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

.search-box {
    flex: 1;
    display: flex;
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    overflow: hidden;
}

.search-box input {
    flex: 1;
    border: none;
    padding: 8px 15px;
    font-size: 14px;
    outline: none;
    background: transparent;
}

.search-box button {
    padding: 8px 15px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
}

.nav-categories {
    display: flex;
    overflow-x: auto;
    padding: 0 10px 10px;
    gap: 5px;
    -webkit-overflow-scrolling: touch;
}

.nav-categories::-webkit-scrollbar {
    display: none;
}

.nav-categories .nav-item {
    padding: 6px 14px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 14px;
    border-radius: 15px;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-categories .nav-item.active,
.nav-categories .nav-item:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* 轮播 Banner */
.banner-section {
    position: relative;
    margin: 10px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.banner-slider {
    position: relative;
    height: 160px;
}

.banner-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s;
    display: flex;
    align-items: center;
    padding: 20px;
}

.banner-item.active {
    opacity: 1;
}

.banner-content {
    color: white;
}

.banner-tag {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 10px;
}

.banner-content h2 {
    font-size: 24px;
    margin-bottom: 5px;
}

.banner-content p {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 12px;
}

.banner-btn {
    padding: 8px 20px;
    background: white;
    color: var(--accent);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.banner-dots {
    position: absolute;
    bottom: 10px;
    right: 15px;
    display: flex;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.3s;
}

.dot.active {
    background: white;
    width: 20px;
    border-radius: 4px;
}

/* 主内容区 */
.main-content {
    padding: 0 10px;
}

/* 快捷分类 */
.quick-categories {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    background: var(--bg-card);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 0;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.cat-item:active {
    background: var(--bg-primary);
}

.cat-icon {
    font-size: 28px;
}

.cat-name {
    font-size: 13px;
    font-weight: 500;
}

.cat-count {
    font-size: 11px;
    color: var(--text-muted);
}

/* 区块样式 */
.section {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 15px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.more-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.tabs {
    display: flex;
    gap: 15px;
}

.tab {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding-bottom: 2px;
}

.tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

/* 书籍网格 */
.book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.book-card {
    cursor: pointer;
}

.book-cover {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover .placeholder {
    font-size: 36px;
}

.book-cover .status-tag {
    position: absolute;
    top: 5px;
    left: 5px;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.book-card .title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 3px;
}

.book-card .author {
    font-size: 12px;
    color: var(--text-muted);
}

/* 排行榜 */
.rank-list {
    display: flex;
    flex-direction: column;
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.rank-item:last-child {
    border-bottom: none;
}

.rank-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-right: 12px;
    border-radius: 4px;
}

.rank-num.top1 { background: #ff6b6b; color: white; }
.rank-num.top2 { background: #ffa94d; color: white; }
.rank-num.top3 { background: #ffd43b; color: white; }

.rank-info {
    flex: 1;
    min-width: 0;
}

.rank-info .title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-info .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.rank-hot {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* 推荐列表 */
.recommend-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.recommend-item {
    display: flex;
    gap: 12px;
    cursor: pointer;
}

.recommend-item .cover {
    width: 80px;
    height: 107px;
    border-radius: 6px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    overflow: hidden;
}

.recommend-item .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recommend-item .info {
    flex: 1;
    min-width: 0;
}

.recommend-item .title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 5px;
}

.recommend-item .author {
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 5px;
}

.recommend-item .desc {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

.recommend-item .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* 更新列表 */
.update-list {
    display: flex;
    flex-direction: column;
}

.update-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.update-item:last-child {
    border-bottom: none;
}

.update-item .title {
    font-size: 14px;
    font-weight: 500;
}

.update-item .chapter {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.update-item .time {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 搜索遮罩 */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    justify-content: center;
    padding-top: 60px;
}

.search-results {
    background: white;
    width: 100%;
    max-width: 750px;
    max-height: 80vh;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.search-header h3 {
    font-size: 16px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.search-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
}

/* 加载动画 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    margin-top: 15px;
    color: var(--text-secondary);
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    max-width: 750px;
    margin: 0 auto;
    z-index: 100;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 5px 20px;
    color: var(--text-muted);
}

.bottom-nav .nav-item.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 20px;
}

.nav-text {
    font-size: 11px;
}

/* 赞助弹窗 */
.donate-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    position: relative;
}

.modal-content .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 10px;
}

.modal-content > p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.donate-qr {
    margin-bottom: 20px;
}

.qr-placeholder {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.donate-crypto {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: var(--radius);
}

.donate-crypto p {
    font-size: 13px;
    margin-bottom: 8px;
}

.donate-crypto code {
    display: block;
    font-size: 11px;
    word-break: break-all;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.donate-crypto button {
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* 响应式 */
@media (max-width: 480px) {
    .quick-categories {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .book-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

/* 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    .app {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
}
