.books-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.book-card {
    border-radius: 12px;
    background-color: var(--container-highlight);
    color: var(--text-color);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.book-card:hover {
    transform: translateY(-5px);
    background-color: #333;
    border-color: var(--primary-color);
}

.book-card img {
    border-radius: 8px;
    width: auto;
    height: 200px;
    object-fit: cover;
}

.book-card .book-info {
    flex: 1;
}

.book-number {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 5px;
}

.book-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color-dark);
    margin-bottom: 5px;
}

.book-subtitle {
    font-size: 14px;
    margin-bottom: 15px;
    color: var(--text-color-dark);
}

.lesson-count {
    background: rgba(29, 185, 84, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--primary-color);
    display: inline-block;
}

.history-section {
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    margin-bottom: 20px;
}
.book-container.history-section.collapsed {
    padding: 10px 16px 14px;
}
.history-section::before {
    content: "";
    position: absolute;
    top: -45%;
    right: -25%;
    width: 70%;
    height: 170%;
    background: radial-gradient(circle at top right, rgba(29, 185, 84, 0.2), transparent 65%);
    pointer-events: none;
}
.history-section > * {
    position: relative;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.history-section.collapsed .history-header {
    gap: 14px;
}
.history-title-group {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 1;
    min-width: 240px;
}
.history-section.collapsed .history-title-group {
    gap: 12px;
    min-width: 200px;
}
.history-title-group h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 0;
}
.history-section.collapsed .history-title-group h3 {
    font-size: 1.05em;
}
.history-subtitle {
    margin-top: 4px;
    font-size: 0.85em;
    color: var(--text-color-dark);
    letter-spacing: 0.3px;
}
.history-section.collapsed .history-subtitle { display: none; }
.history-icon {
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    padding: 8px;
    background: linear-gradient(135deg, rgba(29, 185, 84, 0.35), rgba(29, 185, 84, 0.12));
    box-shadow: 0 10px 24px rgba(29, 185, 84, 0.2);
}
.history-section.collapsed .history-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    padding: 5px;
}
.history-icon span {
    width: 5px;
    border-radius: 3px;
    background: var(--primary-color);
    opacity: 0.75;
}
.history-icon span:nth-child(1) { height: 16px; }
.history-icon span:nth-child(2) { height: 26px; }
.history-icon span:nth-child(3) { height: 20px; }
.history-toggle-btn {
    display: none;
    border-radius: 999px;
    padding: 7px 18px;
    border: 1px solid rgba(29, 185, 84, 0.45);
    background: rgba(29, 185, 84, 0.12);
    color: var(--text-color);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.history-section.collapsed .history-toggle-btn {
    padding: 4px 12px;
    font-size: 0.75em;
}
.history-toggle-btn:hover {
    background: rgba(29, 185, 84, 0.22);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.history-divider {
    border-top-color: rgba(255, 255, 255, 0.08);
    margin: 14px 0 20px;
}
.history-section.collapsed .history-divider { display: none; }
#history-list {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    scroll-snap-type: x mandatory;
}
.history-section.collapsed #history-list { display: none; }
#history-list::-webkit-scrollbar {
    height: 6px;
}
#history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}
.history-card {
    background: rgba(33, 33, 33, 0.95);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    width: 180px;
    scroll-snap-align: start;
}
.history-card:hover {
    transform: translateY(-6px) scale(1.015);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    border-color: rgba(29, 185, 84, 0.5);
}
.history-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
}
.history-preview {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.2s ease, background 0.2s ease;
    text-decoration: none;
    color: inherit;
    min-height: 48px;
    margin-top: 6px;
}
.history-preview:hover {
    border-color: rgba(29, 185, 84, 0.45);
    background: rgba(29, 185, 84, 0.12);
}
.history-preview img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
}
.history-preview-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-preview-label {
    font-size: 0.75em;
    color: var(--text-color-dark);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.history-preview-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.3;
}
.history-section.collapsed .history-preview { display: flex; }
.history-card-info {
    padding: 12px 14px 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.history-card-title {
    font-weight: 600;
    font-size: 0.95em;
    margin: 0;
    color: var(--text-color);
    line-height: 1.4;
}
.history-card-book {
    font-size: 0.75em;
    color: var(--text-color-dark);
    margin: 0;
    letter-spacing: 0.4px;
}
.history-list-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    overflow: visible;
    padding-bottom: 0;
    scroll-snap-type: none;
}
.history-list-grid .history-card {
    min-width: 0;
    width: 100%;
}

@media (max-width: 768px) {
    .books-nav {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .book-card {
        text-align: center;
    }
    .book-card img {
        margin: 15px;
        max-height: 35vw;
    }
    .book-card .book-info {
        text-align: center;
    }
        .history-title-group {
        gap: 14px;
    }
    .history-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        padding: 6px;
    }
    .history-card {
        min-width: 160px;
        width: 160px;
    }
    .history-card img {
        height: 100px;
    }
}