* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('JetBrainsMono-Medium.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

body {
    background-color: #fff;
    color: #000;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px; /* Единый кегль для всего */
    font-weight: 400;
    line-height: 1.2;
    padding: 20px;
}

/* Шапка */
.header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0;
}

.action {
    text-align: right;
}

.portfolio-section {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    margin-bottom: 0;
}

/* Сетка */
.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 колонок на ПК */
    gap: 10px;
    order: 1; /* Сетка сверху на ПК */
    margin-bottom: 0;
}

.grid-item {
    aspect-ratio: 4 / 3; /* Жестко заданная пропорция */
    background-color: #e9e9e9; /* Тёмно-серый фон для полей */
    overflow: hidden;
    cursor: pointer;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Картинка помещается целиком, добавляются поля */
    display: block;
}

.section-title {
    font-size: 1em;
    font-weight: 400;
    order: 2; /* Заголовок снизу на ПК */
}

/* Lightbox (Просмотр фото) */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.95);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    display: block;
    width: auto;
    height: auto;
    max-width: 90%;
    max-height: 80vh; /* Ограничиваем высоту, чтобы влез заголовок и кнопки */
    object-fit: contain;
}

.nav-btns {
    position: static; /* Кнопки идут сразу за картинкой */
    margin-top: 15px;
    display: flex;
    gap: 50px;
}

.nav-btns button {
    background: none;
    border: none;
    padding: 2px 8px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    font-size: 10px;
}

#slideCounter {
    align-self: center;
    font-family: 'JetBrains Mono', monospace;
}

/* Заголовок в лайтбоксе */
.lightbox-title {
    position: static;
    width: auto;
    text-align: center;
    color: #000;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px; /* Стандартный размер ПК */
    margin-bottom: 5px; /* Минимальный отступ до картинки */
}

/* Мобильная версия */
@media (max-width: 768px) {
    body {
        font-size: 9px;
        padding: 10px;
    }

    .header {
        flex-direction: row;
        gap: 0;
    }

    .bio {
        width: auto;
        text-align: right;
    }

    .bio-dept {
        display: block; /* Перенос на новую строку на телефоне */
        text-align: right;
    }

    .bio-tg {
        text-align: right;
    }

    .section-title {
        order: 1; /* Заголовок сверху на телефоне */
        margin-bottom: 5px;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr); /* 2 колонки на телефоне */
        order: 2; /* Сетка снизу на телефоне */
        margin-bottom: 0; /* На телефоне сетка снизу, отступ не нужен */
    }

    /* Lightbox mobile styles */
    .lightbox-content {
        max-height: 80%; /* Уменьшаем высоту, чтобы кнопки точно влезли в экран */
        max-width: 80%;
    }
    .nav-btns {
        gap: 15px; /* Уменьшаем отступы между кнопками */
        width: 100%;
        justify-content: center;
    }
    .nav-btns button {
        font-size: 14px; /* Увеличиваем кнопки, чтобы заполнить пространство */
        padding: 10px 20px;
        white-space: nowrap;
    }
    .lightbox-title {
        font-size: 9px;
    }
}