:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3f37c9;
    --dark: #1d3557;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --success: #4cc9f0;
    --warning: #f8961e;
    --danger: #e63946;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
    
    /* 浅色主题变量 */
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #1d3557;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --header-bg: #ffffff;
}

.dark-mode {
    /* 深色主题变量 */
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e9ecef;
    --text-secondary: #a0a0a0;
    --border-color: #2d2d2d;
    --header-bg: #1e1e1e;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    min-height: 100vh;
    transition: var(--transition);
    padding: 0 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 0;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    background: var(--header-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--success));
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 700;
    transition: var(--transition);
}

.header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    transition: var(--transition);
}

.theme-toggle {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;

    background: var(--card-bg);
    border: none;
    z-index: 98;

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-direction: column;

    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: rotate(15deg);
}

.theme-toggle i {
    font-size: 1.3rem;
    color: var(--text-color);
    transition: var(--transition);
}

.controls {
    display: block;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-container {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text-color);
}

.search-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: var(--transition);
}

.filter-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
}

.filter-btn:hover, .filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.stats {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
}

.stat-card {
    background: var(--card-bg);
    padding: 5px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.stat-card i {
    font-size: 1.5rem;
    color: var(--primary);
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.book-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.book-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid transparent;
}

.book-card-content {
    padding: 5px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    transition: var(--transition);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-author {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: var(--transition);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-tags {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 20px 15px 10px;
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.book-card:hover .book-tags {
    transform: translateY(0);
    opacity: 1;
}

.book-card a:target{
    background: linear-gradient(to right, var(--primary), var(--success));
    color: #e9ecef;
}

.book-card a:target .book-title, .book-card a:target .book-author{
    color: #e9ecef;
}

.book-tag {
    background: var(--border-color);
    color: var(--text-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition);
}

.book-tag:hover {
    background: var(--primary);
    color: white;
    cursor: pointer;
}

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

.book-format {
    background: var(--primary-light);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.book-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.reading-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 99;
}

.control-name {
    font-size: 0.5rem;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    border: none;
    flex-direction: column;
}

.control-btn:hover {
    background: var(--secondary);
    transform: scale(1.1);
}

.footer {
    text-align: center;
    padding: 10px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    transition: var(--transition);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: var(--border-color);
}

.book-icon {
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.tag-cloud-item {
    background: var(--card-bg);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    color: var(--text-color);
}

.tag-cloud-item:hover, .tag-cloud-item.active {
    background: var(--primary);
    color: white;
}

@media (max-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .stats {
        flex-direction: row;
        align-items: center;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container {
        min-width: 100%;
    }
}

.kindle-mode header, .kindle-mode .tag-cloud-item, .kindle-mode .book-cover, .kindle-mode .book-card, .kindle-mode .theme-toggle, .kindle-mode .control-btn, .kindle-mode .search-box {
    box-shadow: none;
    border-radius: inherit;
}

.kindle-mode .container {
    padding: 0;
}

.kindle-mode .header {
    margin-bottom: 0;
}

.kindle-mode .theme-toggle {
    border: 1px solid;
}

@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .header {
        padding: 30px 15px;
    }
}