.tags-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 15px 0;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.2s ease-in-out;
    border: 1px solid #ff9800;
}

/* Обычный тег */
.tag-default {
    background-color: transparent;
    color: #ff9800;
}

.tag-default:hover {
    background-color: #ffe0b2;
}

/* Активный тег */
.tag-active {
    background-color: #ff9800;
    color: #ffffff;
}

.tag-active:hover {
    background-color: #f57c00;
}

/* Счетчик внутри тега */
.tag-count {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 колонки на мобилках */
    grid-auto-rows: 250px; /* Базовая высота ячейки */
    grid-auto-flow: dense; /* Умное заполнение пустот */
    gap: 15px;
    padding: 15px;
}

@media (min-width: 992px) {
    .prompt-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 колонки на десктопе */
    }
}

/* 1, 7, 13... — ШИРОКИЕ (занимают 2 колонки в ширину) */
/* Формула: 6n + 1 */
.prompt-grid > div:nth-child(6n+1) {
    grid-column: span 2;
}

/* 2, 8, 14... — ВЫСОКИЕ (2 строки) */
/* Раньше было 6n+4, теперь 6n+2 */
.prompt-grid > div:nth-child(6n+2) {
    grid-row: span 2;
}

/* Стили карточки внутри */
.gallery-card {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    overflow: hidden;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Картинка всегда заполняет блок без искажений */
    display: block;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Оверлей как на скрине */
.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 15px;
    color: #fff;
}

.btn-prompt {
    background: #fff;
    color: #000;
    border-radius: 8px;
    padding: 5px 15px;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    width: fit-content;
    margin-top: 10px;
    transition: 0.2s;
}

.btn-prompt:hover {
    background: #ddd;
    color: #000;
}

#tags-container.collapsed {
    max-height: calc(34.6px * 2 + 8px + 15px);
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#tags-container.expanded {
    max-height: none;
}

.tag-item.tag-active {
    order: -1;
}

@media (max-width: 680px) {
    .prompt-grid > div:nth-child(6n+1) {
        grid-column: span 1;
    }

    .prompt-grid > div:nth-child(6n+2) {
        grid-row: span 1;
    }

    .prompt-grid {
        gap: 6px;
    }

    #tags-container.collapsed {
        max-height: calc(34.6px * 3 + 8px * 2 + 15px);
    }

    .search-btn {
        width: 100%;
    }
}

/* ================================================
   GALLERY CARD
   ================================================ */

.gallery-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.gallery-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    pointer-events: none;
}

.gallery-card__content {
    pointer-events: auto;
}

.gallery-card__title {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 1px 1px 2px #000;
    margin-bottom: 0.5rem;
}

.btn-prompt {
    width: fit-content;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* ================================================
   PROMPTS PAGE
   ================================================ */

/* Search bar */
.search-bar {
    display: flex;
    gap: 0.5rem;
    max-width: 500px;
    flex-wrap: wrap;
}

@media (min-width: 576px) {
    .search-bar {
        flex-wrap: nowrap;
    }
}

/* Tags container */
.tags-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tags-filter.collapsed {
    max-height: 72px;
    overflow: hidden;
}

.tags-filter.expanded {
    max-height: none;
}

/* Tag items */
.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border: none;
    background: none;
}

.tag-default {
    background: #1e293b;
    color: #94a3b8;
}

.tag-default:hover {
    background: #2d3f5a;
    color: #e2e8f0;
}

.tag-active {
    background: #f59e0b;
    color: #000;
}

.tag-count {
    font-size: 0.72rem;
    opacity: 0.7;
}

/* ================================================
   IMAGE MODAL
   ================================================ */

.modal-image {
    width: max-content;
    max-width: 95vw;
}

.modal-image .modal-content {
    width: max-content;
}

.modal-image .modal-body {
    width: max-content;
}

.popup-img {
    max-height: 90vh;
    cursor: default;
}

/* ================================================
   GALLERY CARD
   ================================================ */

.gallery-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.gallery-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: transform 0.3s;
}

.gallery-card:hover .gallery-card__img {
    transform: scale(1.03);
}

.gallery-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-card:hover .gallery-card__overlay {
    opacity: 1;
}

.gallery-card__content {
    pointer-events: auto;
}

.gallery-card__title {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 1px 1px 2px #000;
    margin-bottom: 0.5rem;
}

.btn-prompt {
    width: fit-content;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* ================================================
   PROMPT GRID
   ================================================ */

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

@media (max-width: 576px) {
    .prompt-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}