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

:root {
    --m24-blue: #0066cc;
    --m24-dark-blue: #004499;
    --m24-light-blue: #e6f2ff;
    --m24-gray: #f5f5f5;
    --m24-dark-gray: #666666;
    --m24-text: #333333;
    --m24-border: #e0e0e0;
    --bg-0: #0b1220;
    --bg-1: #121a2a;
    --surface-0: rgba(255, 255, 255, 0.06);
    --surface-1: rgba(255, 255, 255, 0.10);
    --border-0: rgba(148, 163, 184, 0.22);
    --text-0: #e2e8f0;
    --text-1: rgba(226, 232, 240, 0.85);
    --text-2: rgba(226, 232, 240, 0.65);
    --shadow-1: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 16px 50px rgba(0, 0, 0, 0.45);
    --ring: 0 0 0 3px rgba(0, 102, 204, 0.35);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(1200px 600px at 30% -10%, rgba(0, 102, 204, 0.30), transparent 60%), radial-gradient(900px 480px at 90% 20%, rgba(255, 255, 255, 0.06), transparent 55%), linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 55%, #0b1426 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 0;
    color: var(--text-0);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

/* Зимняя анимация снежинок */

.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.mandarins {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -10px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    animation: fall linear infinite;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.75);
}

.mandarin {
    position: absolute;
    top: -14px;
    font-size: 1.6em;
    opacity: 0.85;
    filter: drop-shadow(0 0 10px rgba(255, 140, 0, 0.25));
    animation: mandarin-fall linear infinite;
    will-change: transform;
}

.mandarin:nth-child(1) {
    left: 8%;
    animation-duration: 16s;
    animation-delay: 0s;
    font-size: 1.35em;
}

.mandarin:nth-child(2) {
    left: 18%;
    animation-duration: 18s;
    animation-delay: 1s;
    font-size: 1.55em;
    opacity: 0.78;
}

.mandarin:nth-child(3) {
    left: 33%;
    animation-duration: 20s;
    animation-delay: 2.2s;
    font-size: 1.25em;
    opacity: 0.72;
}

.mandarin:nth-child(4) {
    left: 46%;
    animation-duration: 17s;
    animation-delay: 0.8s;
    font-size: 1.6em;
}

.mandarin:nth-child(5) {
    left: 58%;
    animation-duration: 21s;
    animation-delay: 1.6s;
    font-size: 1.3em;
    opacity: 0.7;
}

.mandarin:nth-child(6) {
    left: 72%;
    animation-duration: 19s;
    animation-delay: 2.7s;
    font-size: 1.45em;
}

.mandarin:nth-child(7) {
    left: 84%;
    animation-duration: 16s;
    animation-delay: 0.4s;
    font-size: 1.7em;
    opacity: 0.82;
}

.mandarin:nth-child(8) {
    left: 92%;
    animation-duration: 22s;
    animation-delay: 1.9s;
    font-size: 1.25em;
    opacity: 0.68;
}

.mandarin>span {
    display: block;
    animation: mandarin-wiggle ease-in-out infinite;
    transform-origin: 50% 60%;
    will-change: transform;
}

.mandarin:nth-child(1)>span {
    animation-duration: 3.6s;
    animation-delay: 0.2s;
}

.mandarin:nth-child(2)>span {
    animation-duration: 4.2s;
    animation-delay: 0.6s;
}

.mandarin:nth-child(3)>span {
    animation-duration: 3.9s;
    animation-delay: 0.1s;
}

.mandarin:nth-child(4)>span {
    animation-duration: 4.6s;
    animation-delay: 0.8s;
}

.mandarin:nth-child(5)>span {
    animation-duration: 3.5s;
    animation-delay: 0.3s;
}

.mandarin:nth-child(6)>span {
    animation-duration: 4.1s;
    animation-delay: 0.4s;
}

.mandarin:nth-child(7)>span {
    animation-duration: 3.8s;
    animation-delay: 0.5s;
}

.mandarin:nth-child(8)>span {
    animation-duration: 4.9s;
    animation-delay: 0.7s;
}

.snowflake:nth-child(1) {
    left: 10%;
    animation-duration: 12s;
    animation-delay: 0s;
    font-size: 1em;
}

.snowflake:nth-child(2) {
    left: 20%;
    animation-duration: 14s;
    animation-delay: 1s;
    font-size: 1.1em;
}

.snowflake:nth-child(3) {
    left: 30%;
    animation-duration: 16s;
    animation-delay: 2s;
    font-size: 0.9em;
}

.snowflake:nth-child(4) {
    left: 40%;
    animation-duration: 13s;
    animation-delay: 0.5s;
    font-size: 1.2em;
}

.snowflake:nth-child(5) {
    left: 50%;
    animation-duration: 15s;
    animation-delay: 1.5s;
    font-size: 1em;
}

.snowflake:nth-child(6) {
    left: 60%;
    animation-duration: 17s;
    animation-delay: 2.5s;
    font-size: 0.95em;
}

.snowflake:nth-child(7) {
    left: 70%;
    animation-duration: 12s;
    animation-delay: 0.3s;
    font-size: 1.1em;
}

.snowflake:nth-child(8) {
    left: 80%;
    animation-duration: 14s;
    animation-delay: 1.3s;
    font-size: 0.9em;
}

.snowflake:nth-child(9) {
    left: 90%;
    animation-duration: 16s;
    animation-delay: 2.3s;
    font-size: 1.05em;
}

.snowflake:nth-child(10) {
    left: 15%;
    animation-duration: 13s;
    animation-delay: 0.7s;
    font-size: 0.95em;
}

.snowflake:nth-child(11) {
    left: 75%;
    animation-duration: 15s;
    animation-delay: 1.7s;
    font-size: 1.1em;
}

.snowflake:nth-child(12) {
    left: 35%;
    animation-duration: 17s;
    animation-delay: 2.7s;
    font-size: 1em;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.7;
    }
    10% {
        opacity: 0.9;
    }
    90% {
        opacity: 0.9;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes mandarin-fall {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
        opacity: 0;
    }
    12% {
        opacity: 0.85;
    }
    50% {
        transform: translate3d(18px, 50vh, 0) rotate(180deg);
    }
    100% {
        transform: translate3d(-18px, 100vh, 0) rotate(360deg);
        opacity: 0;
    }
}

@keyframes mandarin-wiggle {
    0%,
    100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    50% {
        transform: translate3d(0, 0, 0) rotate(10deg);
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* Верхняя панель */

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(11, 18, 32, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-0);
    box-shadow: var(--shadow-1);
    margin-bottom: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-0);
    min-width: 0;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-0);
}

.brand-name {
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-link {
    color: var(--text-1);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.topbar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-0);
    color: var(--text-0);
}

.topbar-link:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* Header-картинка */

.header-image {
    margin-bottom: 18px;
    border-radius: 14px;
    box-shadow: var(--shadow-2);
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1221 / 302;
    background-image: url('header-desktop.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--border-0);
}

/* Адаптация для разных размеров экранов */

@media (max-width: 768px) {
    .header-image {
        aspect-ratio: 370 / 200;
        background-image: url('header-mobile.png');
        border-radius: 12px;
    }
}

/* Тулбар */

/* (полоска поиска убрана по запросу) */

.videos-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.video-item {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    border: 1px solid var(--border-0);
    backdrop-filter: blur(6px);
}

.video-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
    border-color: rgba(0, 102, 204, 0.55);
}

.video-thumbnail {
    width: 100%;
    height: 200px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.video-thumbnail::before {
    content: '▶';
    font-size: 4rem;
    color: white;
    opacity: 0.95;
    z-index: 3;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    background: rgba(0, 102, 204, 0.8);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.video-item:hover .video-thumbnail::before {
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(0, 102, 204, 0.95);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.5);
}

.video-thumbnail img,
.video-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 1;
    /* Предотвращение моргания при загрузке */
    opacity: 1;
    transition: opacity 0.1s ease-in;
    /* Изображения, которые уже загружены, показываются сразу */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Для уже загруженных изображений - мгновенное отображение */

.video-thumbnail img[data-loaded="true"],
.video-thumbnail video[data-loaded="true"] {
    opacity: 1 !important;
    transition: none !important;
    visibility: visible !important;
}

.video-thumbnail video {
    pointer-events: none;
    /* Отключаем взаимодействие с видео-превью */
}

.video-info {
    padding: 16px;
}

.video-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-0);
    margin-bottom: 8px;
    line-height: 1.4;
}

.video-number {
    font-size: 0.9rem;
    color: rgba(147, 197, 253, 0.95);
    font-weight: 700;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 40px;
    padding: 20px;
    background: var(--surface-0);
    border-radius: 14px;
    border: 1px solid var(--border-0);
    box-shadow: var(--shadow-1);
}

.pagination button {
    padding: 10px 16px;
    border: 1px solid var(--border-0);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-0);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    min-width: 44px;
}

.pagination button:hover:not(:disabled) {
    background: var(--m24-blue);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
    border-color: var(--m24-blue);
}

.pagination button:active:not(:disabled) {
    transform: translateY(0);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.04);
}

.pagination button.active {
    background: var(--m24-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.4);
    border-color: var(--m24-blue);
    font-weight: 600;
}

.pagination-info {
    color: var(--text-1);
    font-size: 1rem;
    margin: 0 8px;
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border: 1px solid var(--border-0);
}

/* Футер */

.footer {
    margin-top: 18px;
    padding: 16px 0 6px;
    color: var(--text-2);
    text-align: center;
}

.footer-inner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-0);
}

.footer-sep {
    opacity: 0.7;
}

/* Мобильная оптимизация */

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    /* Уменьшаем количество снежинок на мобильных для лучшей производительности */
    .snowflake:nth-child(n+7) {
        display: none;
    }
    /* Мандаринов поменьше на мобильных */
    .mandarin:nth-child(n+5) {
        display: none;
    }
    .snowflake {
        font-size: 1em;
        opacity: 0.6;
    }
    .mandarin {
        font-size: 1.25em;
        opacity: 0.7;
        filter: none;
    }
    .container {
        padding: 15px;
    }
    .topbar {
        border-radius: 12px;
        padding: 10px 12px;
    }
    .videos-container {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
        margin-bottom: 30px;
    }
    .video-thumbnail {
        height: 140px;
    }
    .video-thumbnail::before {
        font-size: 2.5rem;
        width: 60px;
        height: 60px;
    }
    .video-info {
        padding: 12px;
    }
    .video-title {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    .video-number {
        font-size: 0.8rem;
    }
    .pagination {
        padding: 15px 10px;
        gap: 6px;
        border-radius: 12px;
    }
    .pagination button {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: 40px;
        border-radius: 10px;
    }
    .pagination-info {
        font-size: 0.85rem;
        margin: 0 4px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .videos-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .video-thumbnail {
        height: 120px;
    }
    .video-thumbnail::before {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }
    .video-info {
        padding: 10px;
    }
    .video-title {
        font-size: 0.85rem;
    }
    .video-number {
        font-size: 0.75rem;
    }
    .pagination {
        padding: 12px 8px;
        gap: 4px;
    }
    .pagination button {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 36px;
    }
    .pagination-info {
        font-size: 0.8rem;
        padding: 5px 8px;
    }
}

/* Планшеты */

@media (min-width: 769px) and (max-width: 1024px) {
    .videos-container {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
    }
}

/* Уважение системных настроек */

@media (prefers-reduced-motion: reduce) {
    .snowflake {
        animation: none !important;
    }
    .mandarin {
        animation: none !important;
    }
    .mandarin>span {
        animation: none !important;
    }
    .video-item,
    .pagination button,
    .search-clear,
    .topbar-link,
    .video-thumbnail::before {
        transition: none !important;
    }
}