/* ========== 基础变量和全局样式 ========== */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #e5e5e7;
    --hover-bg: #f0f0f5;
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.12);
    --shadow-heavy: rgba(0, 0, 0, 0.16);
    --scrollbar-bg: #f1f1f3;
    --scrollbar-thumb: #c1c1c4;
    --success-color: #34c759;
    --warning-color: #ff9500;
    --error-color: #ff3b30;
    --info-color: #007aff;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-gradient: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 100%);
    --backdrop-blur: 20px;
    --abstract-bg: rgba(102, 126, 234, 0.03);
    --abstract-bg-2: rgba(118, 75, 162, 0.03);
    --mask-gradient: linear-gradient(180deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.7) 30%,
        rgba(255, 255, 255, 0.9) 60%,
        rgba(255, 255, 255, 1) 100%);
    --button-bg: rgba(102, 126, 234, 0.08);
    --button-hover-bg: rgba(102, 126, 234, 0.15);
    --pulse-color: rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --border-color: #38383a;
    --hover-bg: #2c2c2e;
    --shadow-light: rgba(255, 255, 255, 0.05);
    --shadow-medium: rgba(255, 255, 255, 0.08);
    --shadow-heavy: rgba(255, 255, 255, 0.12);
    --scrollbar-bg: #2c2c2e;
    --scrollbar-thumb: #48484a;
    --glass-bg: rgba(28, 28, 30, 0.9);
    --glass-gradient: linear-gradient(135deg, rgba(28,28,30,0.95) 0%, rgba(28,28,30,0.85) 100%);
    --abstract-bg: rgba(102, 126, 234, 0.08);
    --abstract-bg-2: rgba(118, 75, 162, 0.08);
    --mask-gradient: linear-gradient(180deg, 
        transparent 0%, 
        rgba(28, 28, 30, 0.6) 30%,
        rgba(28, 28, 30, 0.85) 60%,
        rgba(28, 28, 30, 1) 100%);
    --button-bg: rgba(102, 126, 234, 0.15);
    --button-hover-bg: rgba(102, 126, 234, 0.25);
    --pulse-color: rgba(102, 126, 234, 0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

/* ========== 顶部按钮组 ========== */

.theme-toggle, .login-toggle, .home-toggle {
    position: fixed;
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: var(--card-bg);
    box-shadow: 0 2px 8px var(--shadow-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
}

.home-toggle {
    top: 20px;
    right: 20px;
}

.login-toggle {
    top: 70px;
    right: 20px;
}

.theme-toggle {
    top: 120px;
    right: 20px;
}

.theme-toggle:hover, .login-toggle:hover, .home-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px var(--shadow-heavy);
}

.theme-toggle i, .login-toggle i, .home-toggle i {
    font-size: 20px;
    color: var(--text-primary);
}

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

/* ========== 书籍卡片 ========== */

.book-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 20px 60px var(--shadow-light),
                inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: var(--primary-gradient);
    opacity: 0.1;
    filter: blur(40px);
    z-index: -1;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 30px 80px var(--shadow-medium),
                inset 0 1px 0 rgba(255,255,255,0.3);
}

.book-header {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    position: relative;
}

.book-cover-container {
    flex-shrink: 0;
    position: relative;
}

.book-cover {
    width: 140px;
    height: 190px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3),
                0 0 0 1px rgba(255,255,255,0.1);
    background: var(--hover-bg);
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.book-cover:hover {
    transform: translateY(-8px) rotateY(-5deg);
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.4),
                0 0 0 1px rgba(255,255,255,0.2);
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.2) 100%);
    pointer-events: none;
}

.book-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.3;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========== 统计信息 ========== */

.book-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--glass-gradient);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px var(--shadow-light);
    border-color: rgba(102, 126, 234, 0.3);
}

.stat-item:hover::before {
    opacity: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.stat-value {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 700;
}

.stat-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 14px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.6;
}

/* ========== 标签 ========== */

.book-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tag {
    padding: 6px 14px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.tag:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

/* ========== 简介 ========== */

.book-abstract-wrapper {
    position: relative;
    background: linear-gradient(135deg, 
        var(--abstract-bg) 0%, 
        var(--abstract-bg-2) 100%);
    border-radius: 16px;
    padding: 2px;
    margin-bottom: 16px;
}

.book-abstract {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 20px;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 15px;
    text-indent: 2em;
    position: relative;
    max-height: 120px;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}

.book-abstract::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--mask-gradient);
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.book-abstract::before {
    content: '"';
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 48px;
    font-family: Georgia, serif;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.15;
    line-height: 1;
}

.book-abstract.expanded {
    max-height: 500px;
}

.book-abstract.expanded::after {
    opacity: 0;
}

.expand-btn {
    background: var(--button-bg);
    border: none;
    color: #667eea;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border-radius: 100px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    position: relative;
    overflow: hidden;
    height: 36px;
    min-width: 36px;
    width: auto;
    margin: 0 auto;
}

.expand-btn span {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.expand-btn i {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expand-btn:hover {
    background: var(--button-hover-bg);
    box-shadow: 0 8px 24px var(--pulse-color);
    padding: 0 20px 0 0;
    transform: scale(1.05);
}

.expand-btn:hover span {
    max-width: 150px;
    margin-left: -8px;
    margin-right: 8px;
    opacity: 1;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 var(--pulse-color);
    }
    70% {
        box-shadow: 0 0 0 10px transparent;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.expand-btn:not(:hover) {
    animation: pulse 2s infinite;
}

.expand-btn.expanded i {
    transform: rotate(180deg);
}

/* ========== 操作按钮 ========== */

.action-section {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px var(--shadow-light),
                inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    position: sticky;
    top: 10px;
    z-index: 10;
    transition: all 0.3s ease;
}

.action-section:hover {
    box-shadow: 0 15px 50px var(--shadow-medium),
                inset 0 1px 0 rgba(255,255,255,0.3);
}

.action-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn i {
    font-size: 18px;
    position: relative;
    z-index: 1;
}

.btn span {
    position: relative;
    z-index: 1;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--glass-gradient);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-light);
    border-color: rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error-color) 0%, #ff6b6b 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 59, 48, 0.3);
}

.btn-danger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(255, 59, 48, 0.4);
}

/* ========== 章节列表 ========== */

.chapters-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 8px 32px var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.chapters-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--secondary-gradient);
}

.chapters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.chapters-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chapters-title i {
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chapters-count {
    color: var(--text-secondary);
    font-size: 14px;
    background: var(--hover-bg);
    padding: 8px 16px;
    border-radius: 24px;
    font-weight: 600;
    border: 2px solid var(--border-color);
}

.chapters-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.chapters-list::-webkit-scrollbar {
    width: 10px;
}

.chapters-list::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 10px;
}

.chapters-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

.chapters-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a4;
}

.chapter-item {
    padding: 16px 20px;
    background: var(--hover-bg);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.chapter-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.chapter-item:hover::before {
    transform: scaleY(1);
}

.chapter-item:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateX(6px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    border-color: transparent;
}

.chapter-item i {
    color: #764ba2;
    font-size: 16px;
    transition: color 0.3s ease;
}

.chapter-item:hover i {
    color: white;
}

.chapter-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* ========== 模态框 ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    max-width: 90%;
    max-height: 80%;
    min-width: 360px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
    transform: translateY(30px) scale(0.9);
    transition: all 0.3s ease;
    overflow-y: auto;
    border: 2px solid transparent;
    background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
                var(--primary-gradient) border-box;
}

.modal-overlay.show .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title span {
    font-size: 15px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
}

.modal-footer {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

.modal-btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.modal-btn-secondary {
    background: var(--hover-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.modal-btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* ========== Toast ========== */

.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    z-index: 10001;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
    animation: slideDown 0.4s ease, slideUp 0.4s ease 3.6s;
}

.toast.success {
    background: linear-gradient(135deg, var(--success-color) 0%, #2ecc71 100%);
    color: white;
}

.toast.error {
    background: linear-gradient(135deg, var(--error-color) 0%, #e74c3c 100%);
    color: white;
}

.toast.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #f39c12 100%);
    color: white;
}

.toast.info {
    background: linear-gradient(135deg, var(--info-color) 0%, #3498db 100%);
    color: white;
}

@keyframes slideDown {
    from { transform: translate(-50%, -30px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translate(-50%, 0); opacity: 1; }
    to { transform: translate(-50%, -30px); opacity: 0; }
}

/* ========== 下载管理器优化样式 ========== */

.download-manager {
    position: fixed;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 12px 40px var(--shadow-heavy);
    z-index: 1000;
    /* 关键：只对大小和圆角做过渡，不对位置做过渡 */
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
                var(--primary-gradient) border-box;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

@media (min-width: 769px) {
    .download-manager {
        max-height: 70vh;
    }
    
    .download-manager.minimized {
        width: 64px;
        height: 64px;
        border-radius: 32px;
        /* 不在CSS中设置定位，改由JS控制 */
        overflow: visible !important;
    }
    
    .download-manager.expanded {
        width: 480px;
        max-height: 85vh;
        /* 不在CSS中设置定位，改由JS控制 */
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    .download-manager {
        max-height: 85vh;
    }
    
    .download-manager.minimized {
        width: 56px;
        height: 56px;
        border-radius: 28px;
        /* 不在CSS中设置定位，改由JS控制 */
        overflow: visible !important;
    }
    
    .download-manager.expanded {
        width: calc(100% - 24px);
        border-radius: 20px 20px 0 0;
        /* 不在CSS中设置定位，改由JS控制 */
        max-height: 90vh;
        overflow: hidden;
    }
}

/* 下载按钮优化 - 支持进度显示 */
.download-toggle {
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    overflow: visible !important;
}

@media (max-width: 768px) {
    .download-toggle {
        font-size: 22px;
    }
}

.download-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(102, 126, 234, 0.5);
}

.download-toggle:active {
    transform: scale(0.95);
}

/* 进度环直接在按钮上 */
.download-toggle .progress-ring {
    position: absolute;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    top: -4px;
    left: -4px;
    transform: rotate(-90deg);
    pointer-events: none;
}

.download-toggle .progress-ring-bg,
.download-toggle .progress-ring-progress {
    transition: all 0.3s ease;
}

.download-toggle .progress-ring-progress {
    filter: drop-shadow(0 0 6px currentColor);
}

/* 光晕效果 */
.download-toggle .progress-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
    pointer-events: none;
}

.download-toggle.downloading .progress-glow {
    opacity: 0.4;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.5;
    }
}

/* 脉冲边框 */
.download-toggle .pulse-border {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid;
    opacity: 0;
    pointer-events: none;
}

.download-toggle.downloading .pulse-border {
    animation: pulse-border 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-border {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* 水波纹效果 */
.download-toggle .progress-ring-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border-width: 2px;
    border-style: solid;
    transform: translate(-50%, -50%);
    animation: ripple 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
    z-index: -1;
    pointer-events: none;
}

.download-toggle .progress-ring-ripple:nth-child(2) {
    animation-delay: 0.3s;
}

.download-toggle .progress-ring-ripple:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* 旋转动画 */
.download-toggle.downloading .progress-ring {
    animation: rotate-slow 3s linear infinite;
}

@keyframes rotate-slow {
    from { transform: rotate(-90deg); }
    to { transform: rotate(270deg); }
}

/* 完成动画 */
.download-toggle.completed {
    animation: button-complete 0.6s ease;
}

@keyframes button-complete {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.15);
        filter: brightness(1.3);
    }
}

/* 粒子特效 */
.particle-container {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-burst 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.particle-star {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid;
    border-radius: 0;
}

.particle-star::before {
    content: '';
    position: absolute;
    top: 3px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 8px solid;
}

.particle-circle {
    animation: particle-burst-rotate 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst-rotate {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(720deg);
        opacity: 0;
    }
}

.particle-triangle {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid;
    border-radius: 2px;
}

.particle-square {
    border-radius: 2px;
    animation: particle-burst-spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst-spin {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* 下载内容区 */
.download-content {
    display: none;
    padding: 20px;
    max-height: calc(70vh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .download-content {
        padding: 16px;
        max-height: calc(85vh - 60px);
    }
}

.download-content::-webkit-scrollbar {
    width: 8px;
}

.download-content::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 10px;
}

.download-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

.download-manager.expanded .download-content {
    display: block;
}

.download-manager.expanded .download-toggle {
    display: none;
}

.download-options {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .download-options {
        gap: 10px;
        margin-bottom: 16px;
    }
}

.download-option {
    flex: 1;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--hover-bg);
    position: relative;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .download-option {
        padding: 16px 12px;
        min-height: 90px;
        border-radius: 14px;
    }
}

.download-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.download-option:hover {
    border-color: #764ba2;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(118, 75, 162, 0.2);
}

.download-option:hover::before {
    opacity: 0.1;
}

.download-option i {
    font-size: 32px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .download-option i {
        font-size: 28px;
    }
}

.download-option span {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .download-option span {
        font-size: 13px;
    }
}

/* ========== 章节列表 ========== */

.chapters-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 8px 32px var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.chapters-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--secondary-gradient);
}

.chapters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.chapters-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chapters-title i {
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chapters-count {
    color: var(--text-secondary);
    font-size: 14px;
    background: var(--hover-bg);
    padding: 8px 16px;
    border-radius: 24px;
    font-weight: 600;
    border: 2px solid var(--border-color);
}

.chapters-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.chapters-list::-webkit-scrollbar {
    width: 10px;
}

.chapters-list::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 10px;
}

.chapters-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

.chapters-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a4;
}

.chapter-item {
    padding: 16px 20px;
    background: var(--hover-bg);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.chapter-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.chapter-item:hover::before {
    transform: scaleY(1);
}

.chapter-item:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateX(6px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    border-color: transparent;
}

.chapter-item i {
    color: #764ba2;
    font-size: 16px;
    transition: color 0.3s ease;
}

.chapter-item:hover i {
    color: white;
}

.chapter-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* ========== 模态框 ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    max-width: 90%;
    max-height: 80%;
    min-width: 360px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
    transform: translateY(30px) scale(0.9);
    transition: all 0.3s ease;
    overflow-y: auto;
    border: 2px solid transparent;
    background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
                var(--primary-gradient) border-box;
}

.modal-overlay.show .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title span {
    font-size: 15px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
}

.modal-footer {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

.modal-btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.modal-btn-secondary {
    background: var(--hover-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.modal-btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* ========== Toast ========== */

.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    z-index: 10001;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
    animation: slideDown 0.4s ease, slideUp 0.4s ease 3.6s;
}

.toast.success {
    background: linear-gradient(135deg, var(--success-color) 0%, #2ecc71 100%);
    color: white;
}

.toast.error {
    background: linear-gradient(135deg, var(--error-color) 0%, #e74c3c 100%);
    color: white;
}

.toast.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #f39c12 100%);
    color: white;
}

.toast.info {
    background: linear-gradient(135deg, var(--info-color) 0%, #3498db 100%);
    color: white;
}

@keyframes slideDown {
    from { transform: translate(-50%, -30px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translate(-50%, 0); opacity: 1; }
    to { transform: translate(-50%, -30px); opacity: 0; }
}

/* ========== 下载管理器 ========== */

.download-manager {
    position: fixed;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 12px 40px var(--shadow-heavy);
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    background: linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
                var(--primary-gradient) border-box;
}

@media (min-width: 769px) {
    .download-manager {
        max-height: 70vh;
    }
    
    .download-manager.minimized {
        width: 64px;
        height: 64px;
        border-radius: 32px;
        bottom: 24px;
        right: 24px;
        overflow: visible !important;
    }
    
    .download-manager.expanded {
        width: 480px;
        max-height: 85vh;
        right: 50%;
        bottom: 50%;
        transform: translate(50%, 50%);
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    .download-manager {
        max-height: 85vh;
    }
    
    .download-manager.minimized {
        width: 56px;
        height: 56px;
        border-radius: 28px;
        right: 12px;
        bottom: 12px;
        left: auto;
        transform: none;
        overflow: visible !important;
    }
    
    .download-manager.expanded {
        width: calc(100% - 24px);
        border-radius: 20px 20px 0 0;
        bottom: 0;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-height: 90vh;
        overflow: hidden;
    }
}

.download-toggle {
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    overflow: visible !important;
}

@media (max-width: 768px) {
    .download-toggle {
        font-size: 22px;
    }
}

.download-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(102, 126, 234, 0.5);
}

.download-toggle:active {
    transform: scale(0.95);
}

/* 水波纹进度徽章 */
.download-badge {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    pointer-events: none;
    background: transparent;
}

.progress-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 3;
}

.progress-ring-progress {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
    filter: drop-shadow(0 0 6px currentColor);
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.progress-ring-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border-width: 2px;
    border-style: solid;
    transform: translate(-50%, -50%);
    animation: ripple 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
    z-index: -1;
}

.progress-ring-ripple:nth-child(2) {
    animation-delay: 0.3s;
}

.progress-ring-ripple:nth-child(3) {
    animation-delay: 0.6s;
}

.progress-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.download-badge.downloading .progress-glow {
    opacity: 0.4;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.5;
    }
}

.pulse-border {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid;
    opacity: 0;
    animation: pulse-border 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-border {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.download-badge.downloading .pulse-border {
    display: block;
}

@keyframes rotate-slow {
    from { transform: rotate(-90deg); }
    to { transform: rotate(270deg); }
}

.download-badge.downloading .progress-ring {
    animation: rotate-slow 3s linear infinite;
}

@keyframes badge-complete {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.2);
        filter: brightness(1.5);
    }
}

.download-badge.completed {
    animation: badge-complete 0.6s ease;
}

/* 粒子特效 */
.particle-container {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-burst 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.particle-star {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid;
    border-radius: 0;
}

.particle-star::before {
    content: '';
    position: absolute;
    top: 3px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 8px solid;
}

.particle-circle {
    animation: particle-burst-rotate 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst-rotate {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(720deg);
        opacity: 0;
    }
}

.particle-triangle {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid;
    border-radius: 2px;
}

.particle-square {
    border-radius: 2px;
    animation: particle-burst-spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes particle-burst-spin {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* 下载内容区 */
.download-content {
    display: none;
    padding: 20px;
    max-height: calc(70vh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .download-content {
        padding: 16px;
        max-height: calc(85vh - 60px);
    }
}

.download-content::-webkit-scrollbar {
    width: 8px;
}

.download-content::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 10px;
}

.download-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

.download-manager.expanded .download-content {
    display: block;
}

.download-manager.expanded .download-toggle {
    display: none;
}

.download-options {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .download-options {
        gap: 10px;
        margin-bottom: 16px;
    }
}

.download-option {
    flex: 1;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--hover-bg);
    position: relative;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .download-option {
        padding: 16px 12px;
        min-height: 90px;
        border-radius: 14px;
    }
}

.download-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.download-option:hover {
    border-color: #764ba2;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(118, 75, 162, 0.2);
}

.download-option:hover::before {
    opacity: 0.1;
}

.download-option i {
    font-size: 32px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .download-option i {
        font-size: 28px;
    }
}

.download-option span {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .download-option span {
        font-size: 13px;
    }
}

/* 下载任务 */
.download-task {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--hover-bg);
    border-radius: 14px;
    border-left: 4px solid;
    border-image: var(--primary-gradient) 1;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .download-task {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 12px;
    }
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 8px;
}

.task-name {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 700;
    flex: 1;
    word-break: break-word;
}

@media (max-width: 768px) {
    .task-name {
        font-size: 13px;
    }
}

.task-status {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--card-bg);
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .task-status {
        font-size: 11px;
        padding: 3px 8px;
    }
}

.task-status.success {
    background: var(--success-color);
    color: white;
}

.task-status.error {
    background: var(--error-color);
    color: white;
}

.task-status.warning {
    background: var(--warning-color);
    color: white;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.download-action-btn {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .download-action-btn {
        padding: 10px 14px;
        font-size: 12px;
    }
}

.download-action-btn.btn-warning {
    background: var(--warning-color);
    color: white;
}

.download-action-btn.btn-warning:hover {
    background: #e68a00;
    transform: translateY(-2px);
}

.download-action-btn.btn-secondary {
    background: var(--secondary-gradient);
    color: white;
}

.download-action-btn.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.3);
}

.download-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.retry-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 2px solid var(--border-color);
}

.failed-chapters-header {
    font-size: 13px;
    color: var(--error-color);
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 768px) {
    .failed-chapters-header {
        font-size: 12px;
    }
}

.failed-chapters-list {
    max-height: 150px;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.failed-chapters-list::-webkit-scrollbar {
    width: 6px;
}

.failed-chapters-list::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 6px;
}

.failed-chapters-list::-webkit-scrollbar-thumb {
    background: var(--error-color);
    border-radius: 6px;
}

.failed-chapter-item {
    font-size: 12px;
    color: var(--error-color);
    margin-bottom: 6px;
    padding: 6px 10px;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 6px;
    word-break: break-word;
}

@media (max-width: 768px) {
    .failed-chapter-item {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-primary);
}

.spinner {
    display: inline-block;
    width: 56px;
    height: 56px;
    border: 4px solid var(--border-color);
    border-radius: 50%;
    border-top: 4px solid transparent;
    background: var(--primary-gradient);
    background-clip: border-box;
    animation: spin 1.2s ease-in-out infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@media (max-width: 768px) {
    .container {
        padding: 50px 12px 80px;
    }

    .theme-toggle,
    .login-toggle,
    .home-toggle {
        width: 40px;
        height: 40px;
    }

    .home-toggle {
        top: 12px;
        right: 12px;
    }

    .login-toggle {
        top: 58px;
        right: 12px;
    }

    .theme-toggle {
        top: 102px;
        right: 12px;
    }

    .book-card {
        padding: 20px;
        border-radius: 20px;
        margin-bottom: 16px;
    }

    .book-header {
        flex-direction: column;
        gap: 16px;
        align-items: center;
        text-align: center;
    }

    .book-cover {
        width: 120px;
        height: 160px;
        border-radius: 12px;
    }

    .book-title {
        font-size: 22px;
        text-align: center;
    }

    .book-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .stat-item {
        flex: 0 0 auto;
        min-width: 80px;
        padding: 10px 12px;
        text-align: center;
        border-radius: 10px;
    }

    .stat-label {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .stat-value {
        font-size: 13px;
    }

    .stat-icon {
        display: none;
    }

    .book-tags {
        justify-content: center;
        gap: 6px;
    }

    .tag {
        padding: 4px 10px;
        font-size: 11px;
        border-radius: 16px;
    }

    .book-abstract {
        max-height: 100px;
        font-size: 14px;
        padding: 16px;
    }

    .book-abstract::after {
        height: 50px;
    }

    .expand-btn:hover span {
        max-width: 100px;
    }

    .action-section {
        position: relative;
        top: auto;
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 16px;
    }

    .action-buttons {
        display: flex;
        gap: 8px;
    }

    .btn {
        flex: 1;
        font-size: 12px;
        padding: 12px 8px;
        min-height: 44px;
        border-radius: 12px;
        flex-direction: column;
        gap: 4px;
    }

    .btn i {
        font-size: 16px;
    }

    .btn span {
        font-size: 11px;
    }

    .chapters-card {
        padding: 16px;
    }

    .chapters-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .chapters-title {
        font-size: 16px;
    }

    .chapters-count {
        padding: 4px 10px;
        font-size: 12px;
    }

    .chapters-list {
        grid-template-columns: 1fr;
        max-height: 300px;
        gap: 8px;
    }

    .chapter-item {
        padding: 12px 14px;
        font-size: 14px;
    }

    .modal {
        max-width: calc(100% - 24px);
        padding: 20px;
        border-radius: 16px;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 45px 8px 70px;
    }

    .book-card {
        padding: 16px;
        border-radius: 16px;
    }

    .book-cover {
        width: 100px;
        height: 135px;
    }

    .book-title {
        font-size: 20px;
    }

    .stat-item {
        min-width: 70px;
        padding: 8px 10px;
    }

    .chapters-card {
        padding: 12px;
    }

    .chapters-list {
        max-height: 250px;
    }

    .chapter-item {
        padding: 10px 12px;
        font-size: 13px;
    }
}