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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f4f6f9;
    color: #333333;
    line-height: 1.5;
    padding: 2rem 1rem;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
}

header {
    position: sticky;
    top: 0;
    z-index: 100; /* Чтобы шапка всегда была поверх карточек */
    background-color: #f4f6f9; /* Должен совпадать с фоном body */
    padding: 1.5rem 0; /* Внутренние отступы */
    margin-bottom: 2rem;
    border-bottom: 2px solid #e2e8f0;
    transition: box-shadow 0.2s ease;
}

/* Добавим тень при прокрутке, чтобы шапка визуально отделялась от контента */
header.is-scrolled {
    background-color: rgba(255, 255, 255, 0.95); /* Эффект стекла: белый полупрозрачный */
    backdrop-filter: blur(8px); /* Размытие заднего плана (работает в современных браузерах) */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.5rem; /* Слегка уменьшаем высоту шапки при скролле для компактности */
    border-bottom-color: transparent;
    border-radius: 0 0 0.75rem 0.75rem; /* Аккуратное скругление снизу */
}

header h1 {
    font-size: 1.5rem; /* Слегка уменьшили размер (был 2rem) */
    color: #1a202c;
    font-weight: 700;
    line-height: 1.25; /* Прижали строки друг к другу при переносе */
}

header p {
    color: #718096;
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.card-body {
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.card-icon {
    width: 3rem;
    height: 3rem;
    background-color: #2b6cb0;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 0.5rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.card-title-block {
    min-width: 0;
    flex-grow: 1;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.card-version {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-family: monospace;
    background-color: #edf2f7;
    color: #4a5568;
    border-radius: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Описание теперь корректно поддерживает абзацы и списки */
.card-desc {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: #4a5568;
    overflow: hidden;
    height: 8.5rem; /* Четко заданная высота текстового блока для выравнивания */
    position: relative;
}

/* Эффект аккуратного затухания текста внизу, если он не влез */
.card-desc::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1.5rem;
    background: linear-gradient(transparent, #ffffff);
    pointer-events: none;
}

.card-desc p {
    margin-bottom: 0.5rem;
}

.card-desc .desc-list {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
    list-style-type: disc;
}

.card-desc .desc-list li {
    margin-bottom: 0.2rem;
}

/* Подвал */
.card-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #edf2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background-color: #ebf8ff;
    color: #2b6cb0;
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    border: 1px solid #bee3f8;
    white-space: nowrap;
}

.card-link {
    color: #3182ce;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.card-link:hover {
    text-decoration: underline;
    color: #2b6cb0;
}

.card-link svg {
    width: 0.85rem;
    height: 0.85rem;
    margin-left: 0.25rem;
    flex-shrink: 0;
}

.card-no-link {
    color: #a0aec0;
    font-style: italic;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Стили для реального логотипа программы */
.card-img-icon {
    width: 3rem;
    height: 3rem;
    object-fit: contain; /* Картинка масштабируется без искажений, вписываясь в размеры */
    border-radius: 0.5rem; /* Аккуратное скругление углов */
    background-color: #ffffff; /* Белый фон на случай, если png прозрачный */
    border: 1px solid #e2e8f0; /* Легкая серая рамка */
    flex-shrink: 0; /* Защита от сжатия соседними блоками */
}

/* Стили для строки живого поиска */
.header-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .header-content > div:first-child {
        max-width: 65%; /* Заголовок займет 65% ширины, не налезая на поиск */
        min-width: 0;
    }
}

.search-wrapper {
    width: 100%;
    max-width: 400px;
}

.search-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 1px solid #cbd5e0;
    border-radius: 0.5rem;
    background-color: #ffffff;
    color: #2d3748;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-wrapper input:focus {
    border-color: #2b6cb0;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: #718096;
    font-size: 1.1rem;
    background: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    margin-top: 2rem;
}

/* Стили для кнопки "Наверх" */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.25rem;
    height: 3.25rem;
    background-color: #2b6cb0;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    
    /* ИСПРАВЛЕНО: Принудительный flex-режим для выравнивания стрелочки */
    display: flex !important; 
    align-items: center;
    justify-content: center;
    
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 99999; /* Максимальный приоритет слоя */
    
    /* Плавное скрытие */
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

/* Класс полной видимости при прокрутке */
.scroll-top-btn.is-visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
}

.scroll-top-btn:hover {
    background-color: #2c5282;
    transform: scale(1.05);
}

.scroll-top-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}
