/* Скрываем мобильные навигации на десктопе */
.mobile-bottom-nav,
.mobile-tabs {
    display: none;
}

.mobile-tabs {
    display: none;               /* скрыто на десктопе */
}

/* ===== Планшеты (ширина 768px и меньше) ===== */
@media (max-width: 768px) {
    .mobile-recipe-back,
    .mobile-recipe-bookmark {
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: box-shadow 0.2s, transform 0.2s;
    }

    .mobile-recipe-back {
        font-size: 2rem;
        color: var(--text);
        margin-right: auto; /* кнопка назад слева */
    }

    .mobile-recipe-bookmark-icon {
        width: 28px;
        height: 28px;
        object-fit: contain;
    }

    .mobile-recipe-back:hover,
    .mobile-recipe-bookmark:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        transform: scale(1.1);
    }

    .mobile-recipe-bookmark {
        margin-left: auto; /* кнопка закладки справа */
    }

    .recipe-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
    .recipe-card.quick-active {
        outline: 2px solid var(--primary);
        outline-offset: -2px;
        box-shadow: 0 12px 35px rgba(0,0,0,0.4);
        z-index: 9999;
    }


    /* Шапка */
    .header {
        position: relative;
    }
    .header .container {
        flex-wrap: nowrap;
        justify-content: flex-start;   /* убираем space-between, элементы идут друг за другом */
        align-items: center;
        padding: 0 12px;
    }
    .logo {
        font-size: 1.3rem;
        text-align: left;
        flex-shrink: 0;
        margin-right: auto;
    }
    .theme-toggle {
        flex-shrink: 0;
    }
    .notification-bell {
        flex-shrink: 0;
        margin-left: auto;
    }

    .theme-toggle,
    .notification-bell {
        margin-left: 10px;             /* отступ между кнопками справа */
    }

    /* Полностью скрываем десктопную навигацию и бургер */
    #navAuth,
    .burger-menu {
        display: none !important;
    }

    /* Мобильный таб-бар (Главная, Лента, Закладки) */
    .mobile-tabs {
        display: flex;           /* показываем на мобильных */
        justify-content: space-around;
        align-items: stretch;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        padding: 0;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 95;
    }
    .mobile-tab {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        padding: 10px 8px;
        text-decoration: none;
        color: var(--text-secondary);
        font-size: 1rem;
        font-weight: 500;
        transition: color 0.2s;
        text-align: center;
        white-space: nowrap;
    }
    .mobile-tab.active {
        color: var(--primary);
        font-weight: 700;
    }
    .mobile-tab.active::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: var(--primary);
        border-radius: 2px;
    }

    /* Мобильная нижняя навигация (иконки) */
    .mobile-bottom-nav {
        display: flex;
        justify-content: center;      /* группируем по центру */
        align-items: center;
        gap: 12px;                    /* промежуток между кнопками */
        background: transparent;
        border: none;
        box-shadow: none;
        position: fixed;
        bottom: 16px;
        left: 16px;
        right: 16px;
        height: 64px;
        padding: 0;
        z-index: 1000;
    }

    .mobile-bottom-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        border-radius: 20%;           /* ваш текущий радиус */
        border: 1px solid var(--border);
        background: var(--bg);
        text-decoration: none;
        transition: background 0.2s, border-color 0.2s;
        flex-shrink: 0;               /* чтобы кнопки не сжимались */
    }

    .mobile-bottom-btn .mobile-bottom-img {
        width: 24px;
        height: 24px;
        object-fit: contain;
        display: block;
    }

    /* Если иконки тёмные, в активном состоянии они станут белыми */
    .mobile-bottom-btn.active .mobile-bottom-img {
        filter: brightness(0) invert(1);
    }

    [data-theme="dark"] .mobile-bottom-btn .mobile-bottom-img {
        filter: invert(1);
    }
    [data-theme="dark"] .mobile-bottom-btn.active .mobile-bottom-img {
        filter: brightness(0) invert(0);
    }

    [data-theme="dark"] .mobile-bottom-btn {
        background: #3a2b3c;
        border-color: #4a3b4c;
    }

    .mobile-bottom-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }


    /* Контент не должен перекрываться нижней панелью */
    main {
        padding-bottom: 100px;
    }

    /* Сетка рецептов */
    .masonry-grid {
        columns: 2 240px;
        column-gap: 12px;
        padding: 12px 0;
    }

    /* Страница рецепта */
    .recipe-layout {
        flex-direction: column;
    }
    .recipe-left,
    .recipe-right {
        width: 100%;
        flex: auto;
    }
    .recipe-media-item {
        max-height: 300px;
    }
    .recipe-actions-bar {
        flex-wrap: wrap;
    }

    /* Фильтры */
    .filters-bar {
        gap: 6px;
        padding-bottom: 6px;
    }
    .filter-button {
        padding: 6px 10px;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    .filter-icon {
        width: 18px;
        height: 18px;
    }

    /* Профиль */
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .profile-avatar-xl {
        width: 120px;
        height: 120px;
    }

    /* Формы */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .auth-form {
        padding: 1.5rem;
        margin: 10px;
    }

    /* Комментарии */
    .comment.reply {
        margin-left: 20px;
    }

    .profile-dropdown-menu {
        position: fixed;
        top: auto;
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        max-height: 60vh;
        overflow-y: auto;
        z-index: 999;
    }

    .header-actions {
        order: 3;
        display: flex;
        align-items: center;
        gap: 10px;
    }

        /* Скрываем стрелки карусели на мобильных */
    .carousel-arrow.left,
    .carousel-arrow.right,
    .carousel-arrow {
        display: none !important;
    }

    /* Уменьшаем отступы карусели, так как стрелок больше нет */
    .feed-carousel {
        padding-left: 12px;
        padding-right: 12px;
    }

        .similar-recipes-grid {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 8px;
    }
    .similar-recipe-card {
        flex: 0 0 200px;
    }

    .recipe-layout {
        flex-direction: column;
        align-items: stretch;
    }

    .recipe-left,
    .recipe-right {
        display: contents;   /* потомки становятся прямыми flex-элементами */
    }

    .servings-calculator, .meta-panel{
        width: 100%;
    }

    body.grid-uniform .masonry-grid {
        align-items: stretch;
        row-gap: 8px;
        column-gap: 8px;
        grid-template-columns: repeat(2, 1fr);
    }

    body.grid-uniform .masonry-grid .recipe-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    body.grid-uniform .masonry-grid .card-media {
        aspect-ratio: 1 / 1;
        width: 100%;
        overflow: hidden;
    }

    body.grid-uniform .masonry-grid .card-media > img,
    body.grid-uniform .masonry-grid .card-media > video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* ===== Смартфоны (ширина 480px и меньше) ===== */
@media (max-width: 480px) {
    .meta-note {
        white-space: unset;
    }

    .nutrition-card {
        flex: 1;
        min-width: 70px;
        background: #FFFF00;
        border: 1px solid #FFFF00;
        border-radius: 12px;
        padding: 8px;
        text-align: center;
        box-sizing: border-box;
        max-width: 90px;
    }

    .nutrition-value {
        font-size: 1rem;
        font-weight: 700;
        color: black;
        line-height: 1.2;
    }

    .meta-icon-img {
        width: 25px;
        height: 25px;
        vertical-align: middle;
        margin-right: 4px;
    }

    .star-img {
        width: 25px;
        height: 25px;
        vertical-align: middle;
        margin-right: 2px;
    }

    .meta-panel .star {
        font-size: 1.7rem;
        color: #ccc;
    }

    .servings-calculator, .meta-panel{
        width: 100%;
    }
    /* Две колонки карточек */
    .masonry-grid {
        columns: 2 140px;   /* минимальная ширина колонки 160px */
        column-gap: 8px;
        padding: 10px 0;
    }

    .recipe-card {
        margin-bottom: 8px;
        border-radius: 8px;
        break-inside: avoid;
        -webkit-column-break-inside: avoid;
        page-break-inside: avoid;
        min-width: 110px;
    }

    /* Квадратный контейнер для медиа */
    .card-media {
        position: relative;
        width: 100%;
        overflow: hidden;
        border-radius: 8px;
        background: #f0f0f0;
        line-height: 0;
    }

    .card-media > img,
    .card-media > video {
        width: 100%;
        height: auto;
        display: block;
        object-fit: cover; /* или cover, но не влияет, так как высота auto */
    }

    /* Бейдж времени */
    .card-time-badge {
        bottom: 6px;
        right: 6px;
        font-size: 0.7rem;
        padding: 4px 10px;
        border-radius: 14px;
        gap: 4px;
    }

    .card-time-badge .card-time-icon {
        width: 12px;
        height: 12px;
    }

    .card-body {
        padding: 6px 8px;
    }

    .card-title {
        font-size: 0.8rem;
        margin-bottom: 2px;
        white-space: normal;
        line-height: 1.2;
    }

    /* Индикаторы на медиа */
    .play-indicator {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: 5px;
        right: 5px;
    }

    .bookmark-badge {
        width: 22px;
        height: 22px;
        font-size: 12px;
        top: 5px;
        right: 5px;
    }

    .recipe-title {
        font-size: 1.6rem;
    }

    .recipe-meta-bar {
        gap: 8px;
        font-size: 0.9rem;
    }

    .auth-form {
        max-width: 100%;
        margin: 0 10px;
        padding: 1.2rem;
        border-radius: 16px;
    }
    .auth-form h2 {
        font-size: 1.5rem;
    }

    .profile-avatar-xl {
        width: 100px;
        height: 100px;
    }

    .actions-dropdown {
        right: -10px;
    }

    /* Toast-уведомления */
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        z-index: 9999;
    }

    body.grid-uniform .masonry-grid {
        align-items: stretch;
        row-gap: 8px;
        column-gap: 8px;
    }

    body.grid-uniform .masonry-grid .recipe-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    body.grid-uniform .masonry-grid .card-media {
        aspect-ratio: 1 / 1;
        width: 100%;
        overflow: hidden;
    }

    body.grid-uniform .masonry-grid .card-media > img,
    body.grid-uniform .masonry-grid .card-media > video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}