* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f8f8;
    color: #333;
}

.container {
    max-width: 1460px; /* Wide enough for 5 columns */
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 20px;
    padding: 10px 0;
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    color: #ca2429; /* Xiaohongshu Red */
}

/* 5 Columns Waterfall Layout */
.video-grid {
    column-count: 5; /* CSS Multi-column Layout for Masonry */
    column-gap: 20px;
}

/* Responsive adjustment for smaller screens */
@media (max-width: 1024px) {
    .video-grid {
        column-count: 4;
    }
}
@media (max-width: 768px) {
    .video-grid {
        column-count: 2;
    }
}

.video-card {
    /* Removed background and shadow for no-card look */
    border-radius: 0; 
    overflow: visible;
    display: flex;
    flex-direction: column;
    break-inside: avoid; /* Prevent card from breaking across columns */
    margin-bottom: 20px; /* Space between items vertically */
}

.cover-wrapper {
    position: relative;
    width: 100%;
    background-color: #f0f0f0;
    border-radius: 12px; /* Add radius to image wrapper */
    overflow: hidden;
    /* Skeleton Loading Animation */
    background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Hover effect for play button */
.cover-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.cover-wrapper::after {
    content: '\f04b'; /* FontAwesome Play Icon */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ca2429;
    font-size: 20px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2;
    padding-left: 5px; /* Optical center alignment */
    cursor: pointer;
}

.cover-wrapper:hover::before,
.cover-wrapper:hover::after {
    opacity: 1;
}

.cover-wrapper:hover::after {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.cover-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0; /* Hidden initially for lazy load */
    transition: opacity 0.5s ease;
}

.cover-image.loaded {
    opacity: 1;
}

.video-info {
    padding: 10px;
}

.title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #333;
    text-decoration: none; /* Remove underline from link */
    display: block; /* Make anchor behave like block for clamping */
}

.title:hover {
    color: #ca2429;
}

.video-footer {
    padding: 0 10px 10px 10px;
    font-size: 12px;
    color: #999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-left-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* for truncation to work in nested flex */
}

.avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #eee;
}

.user-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.3;
}

.user-name {
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-text {
    color: #999;
    font-size: 10px;
}

.likes-group {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #666;
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Loading Spinner */
.loading {
    padding: 40px 0;
    text-align: center;
    color: #999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ca2429;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #333;
    z-index: 100;
    transition: all 0.3s ease;
    border: 1px solid #eee;
}

.back-to-top:hover {
    background-color: #f8f8f8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    color: #ca2429;
}