@media (max-width: 560px) {
    .fab { bottom: 16px; }
    .fab-custom { left: 16px; padding: 13px; border-radius: 50%; }
    .fab-custom span { display: none; }
    .fab-top { right: 16px; }
}
@media (hover: none) {
    .product-card:hover {
        transform: none;
        box-shadow: none;
    }
}
@media (max-width: 768px) {
    :root {
        --border-radius: 16px;
    }

    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        padding: 0;
        background: var(--bg-main);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .container {
        width: 100%;
        max-width: none;
        padding-left: 14px;
        padding-right: 14px;
    }

    h1 { font-size: 1.45em; }
    h2 { font-size: 1.32em; }
    h3 { font-size: 1.08em; }

    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    button,
    .header-btn,
    .nav-tab,
    .cabinet-tab {
        min-height: 44px;
        touch-action: manipulation;
    }

    .btn-small {
        min-height: 40px;
        padding: 8px 12px;
    }

    /* На мобильном шапку НЕ делаем липкой: при липкой она перекрывает контент кабинета
       при прокрутке («шапка перекрывает текст»). Тут она прокручивается вместе со страницей. */
    .site-header {
        position: static;
        z-index: auto;
    }
    /* Шапка: липкость теперь у родителя .site-header — здесь статично,
       иначе получается двойной sticky и контент лезет под шапку */
    .header {
        position: static;
        z-index: auto;
        background: transparent;
        margin-bottom: 0;
        padding-top: 4px;
        padding-bottom: 10px;
        border-bottom-color: var(--border-color-thin);
    }
    .site-header { padding-top: max(20px, env(safe-area-inset-top)); }

    .container.header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
        text-align: left;
    }

    .logo-container {
        font-size: 1.05em;
        flex: 0 1 auto;
        min-width: 0;
        white-space: nowrap;
    }

    .header-right-block {
        width: auto;
        margin-left: auto !important;
        gap: 6px;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    #becomeSellerBtn,
    #userMenu .header-btn,
    .header-right-block > .btn-black {
        width: auto;
        flex: 0 0 auto;
        max-width: none;
        margin: 0;
        height: 38px;
        min-height: 38px;
        padding: 0 12px;
        font-size: 0.82em;
        white-space: nowrap;
    }

    #userMenu {
        display: flex;
        flex: 0 0 auto;
        gap: 6px;
        flex-wrap: nowrap;
    }

    /* Верхние вкладки */
    .nav-tabs {
        position: static;
        z-index: 40;
        background: color-mix(in srgb, var(--bg-main) 96%, transparent);
        backdrop-filter: blur(10px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        margin: 0;
        padding-top: 10px;
        padding-bottom: 10px;
        border-bottom-color: var(--border-color-thin);
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar,
    .cabinet-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        flex: 0 0 auto;
        background: var(--bg-card);
        border: 1px solid var(--border-color-thin);
        border-radius: 999px;
        padding: 8px 14px;
        font-size: 0.95em;
        white-space: nowrap;
    }

    .nav-tab.active {
        background: var(--text-main);
        color: var(--bg-card);
        border-color: var(--text-main);
    }

    .nav-tabs .header-btn {
        flex: 0 0 auto;
        margin-left: 0 !important;
        border-radius: 999px;
    }

    .content-section {
        padding-top: 14px;
    }

    #section-catalog {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    /* Поиск и заказ печати */
    .search-filters-container {
        padding: 14px;
        border-radius: 18px;
        margin-bottom: 16px;
        text-align: left;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    }

    .search-input {
        padding-top: 13px;
        padding-bottom: 13px;
        border-radius: 14px;
    }

    .filter-toggle-btn {
        width: 100%;
        margin-top: 12px;
        justify-content: space-between;
        padding: 10px 2px;
        text-align: left;
    }

    .collapsible-filters {
        margin-top: 12px;
        padding-top: 14px;
    }

    .collapsible-filters .grid {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 0;
    }

    .collapsible-filters input[type="text"],
    .collapsible-filters input[type="file"],
    .collapsible-filters select {
        height: 46px;
    }

    .material-row {
        align-items: stretch;
    }

    .btn-help {
        width: 46px;
        height: 46px;
    }

    .filter-buttons-group {
        flex-direction: column;
        gap: 10px;
    }

    .filter-buttons-group button {
        width: 100%;
    }

    /* Карточки — на телефоне 2 в ряд */
    .products-grid,
    .requests-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .product-card,
    .request-card,
    .list-card,
    .form-card {
        border-radius: 18px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    }

    .product-card {
        padding: 12px;
    }

    .product-image-placeholder {
        border-radius: 14px;
        margin-bottom: 12px;
    }

    .product-title {
        font-size: 1em;
        line-height: 1.25;
    }

    .product-price {
        font-size: 1.18em;
    }

    .product-specs,
    .req-specs,
    .list-card-desc {
        line-height: 1.4;
    }

    .item-actions,
    .req-actions,
    .list-card-actions {
        gap: 8px;
    }

    .item-actions button,
    .req-actions button,
    .list-card-actions button {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    .list-card-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .pill {
        align-self: flex-start;
    }

    /* Кабинет: вкладки переносятся на новые строки — видно все сразу, без горизонтальной прокрутки */
    .cabinet-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 8px;
        margin: 12px 0 16px;
        padding: 0;
        scrollbar-width: none;
    }

    .cabinet-tab {
        flex: 0 1 auto;
        white-space: nowrap;
        padding: 8px 13px;
        font-size: 0.88em;
    }

    #cabinet-maker > div:first-child {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    #cabinet-maker > div:first-child .btn-small {
        width: 100%;
    }

    /* Модалки — центрированная карточка, а не «нижняя панель» (короткие формы
       вроде входа/стать мейкером больше не выглядят как пол-экрана снизу) */
    .modal,
    .materials-modal {
        align-items: center;
        padding: 14px;
    }

    .modal[style*="display: block"],
    .materials-modal[style*="display: block"] {
        display: flex !important;
    }

    .modal-content,
    .materials-modal-content {
        width: 100%;
        max-width: 460px;
        max-height: 90dvh;
        margin: auto;
        padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
        border-radius: 20px;
        overflow-y: auto;
    }

    .close-btn {
        top: 14px;
        right: 16px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        background: var(--bg-main);
    }

    .product-details-img {
        height: auto;
        aspect-ratio: 1/1;
        margin-top: 10px;
    }

    .chat-box {
        height: 52dvh;
        max-height: 420px;
    }

    .chat-msg {
        max-width: 88%;
    }

    .star-picker {
        font-size: 1.8em;
        letter-spacing: 2px;
    }

    /* Корзина и checkout */
    #cartItemsList > div {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
        padding: 14px 0 !important;
    }

    #cartItemsList > div > div:nth-child(2) {
        width: 100%;
        justify-content: space-between;
        border-top: 1px dashed var(--border-color-thin);
        padding-top: 10px;
    }

    #checkoutTotal,
    #cartTotalPrice {
        text-align: left !important;
    }
}
@media (max-width: 380px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    #section-catalog {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .products-grid,
    .requests-grid {
        gap: 8px;
    }

    .product-card { padding: 10px; }
    .product-title { font-size: 0.95em; }
    .product-price { font-size: 1.05em; }
    .product-specs { font-size: 0.8em; }

    .search-filters-container,
    .product-card,
    .request-card,
    .list-card,
    .form-card {
        border-radius: 14px;
    }

    .logo-container {
        font-size: 1em;
    }
}
@media (min-width: 1280px) {
    .container { max-width: 1180px; }
    .products-grid { gap: 22px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media (max-width: 420px) { .form-grid-2 { grid-template-columns: 1fr; } }
/* ВАЖНО: брейкпоинт 1023 (а не 900) — синхронно с мобильной навигацией.
   Иначе на 901–1023px получался гибрид: фикс-шапка+таб-бар мобильные, а каталог
   ещё десктопный с sticky-сайдбаром на неверном отступе — «всё съезжало». */
@media (max-width: 1023px) {
    .catalog-layout { grid-template-columns: 1fr; gap: 14px; }
    .catalog-side { position: static; }
    .side-card { padding: 12px; border-color: var(--border-color-thin); }
    .side-card .side-h-first { display: none; }
    .side-h { margin: 12px 0 6px; }
    .catalog-side .cat-bar { flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
        gap: 8px; scrollbar-width: none; padding-bottom: 2px; }
    .catalog-side .cat-bar::-webkit-scrollbar { display: none; }
    .catalog-side .cat-chip { display: inline-block; width: auto; white-space: nowrap; }
}
@media (max-width: 480px) {
    .mk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) { .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; } }
@media (max-width: 640px) {
    .auth-card { min-height: 0; margin: 6vh auto; }
    .auth-overlay { display: none; }
    .auth-pane { position: relative; width: 100%; left: 0; padding: 30px 22px; }
    .auth-pane-register { left: 0; }
    .auth-alt { display: block; }
    .auth-card:not(.mode-register) .auth-pane-register,
    .auth-card.mode-register .auth-pane-login { display: none; }
    .auth-card:not(.mode-register) .auth-pane-login { animation: authSlideL .35s var(--ease-out); }
    .auth-card.mode-register .auth-pane-register { animation: authSlideR .35s var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-pane, .auth-overlay, .auth-ov-content, .auth-ov-decor { animation: none !important; transition: none !important; }
}
@media (max-width: 640px) {
    input, select, textarea { font-size: 16px; }
    .modal-content { width: 94vw; max-width: 94vw; padding: 18px 14px; }
    .catalog-toolbar { flex-wrap: wrap; gap: 8px; }
    #bulkBar { position: static; }               /* sticky-панель не перекрывает контент */
    .item-actions { flex-wrap: wrap; }
    .list-card-head { flex-wrap: wrap; gap: 6px; }
}
@media (max-width: 768px) {
    .toast-root {
        top: auto;
        right: auto;
        bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
        left: 50%;
        transform: translateX(-50%);
        align-items: center;
        max-width: min(420px, calc(100vw - var(--space-6)));
    }

    .toast {
        transform: translateY(16px);
    }

    .toast--in {
        transform: translateY(0);
    }

    .toast--out {
        transform: translateY(16px);
    }
}
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: none;
        opacity: 1;
        transform: none;
    }

    .toast--out {
        opacity: 0;
    }
}
@media (max-width: 640px) {
    .order-stepper {
        padding-left: 4px;
    }

    .order-stepper__track {
        display: none;
    }

    .order-stepper__steps {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        position: relative;
        padding-left: 14px;
        border-left: 2px solid var(--border-color-thin);
    }

    .order-step {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding: 5px 0 5px 8px;
        min-height: 32px;
    }

    .order-step__label {
        display: block;
        text-align: left;
        font-size: 0.8em;
        flex: 1;
    }

    .order-step__dot,
    .order-step__check {
        width: 20px;
        height: 20px;
        font-size: 0.65em;
        margin-left: -25px;
        background: var(--bg-card);
    }

    .order-step--pending .order-step__label {
        color: var(--text-muted);
        opacity: 0.65;
    }

    .order-stepper__mobile-status {
        display: none;
    }

    .order-receive-code {
        width: 100%;
        flex: none;
    }
}
@media (hover: hover) and (pointer: fine) {
    .products-grid > .product-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }

    .products-grid > .product-card:hover .product-image-placeholder img {
        transform: scale(1.04);
    }
}
@media (prefers-reduced-motion: reduce) {
    .product-card--enter {
        animation: none;
        opacity: 1;
        transform: none;
    }

    @media (hover: hover) and (pointer: fine) {
        .products-grid > .product-card:hover {
            transform: none;
            box-shadow: var(--shadow-sm);
        }

        .products-grid > .product-card:hover .product-image-placeholder img {
            transform: none;
        }
    }

    .fly-to-cart {
        display: none !important;
    }

    .cart-badge--pulse {
        animation: none;
    }

    .order-stepper__fill {
        transition: none;
    }

    .order-step--active .order-step__dot {
        animation: none;
    }
}
@media (max-width: 640px) {
    .bids-table thead {
        display: none;
    }

    .bids-table,
    .bids-table tbody,
    .bids-table tr,
    .bids-table td {
        display: block;
        width: 100%;
    }

    .bids-table tbody tr {
        margin-bottom: var(--space-3);
        padding: var(--space-3);
        border: 1px solid var(--border-color-thin);
        border-radius: var(--radius-md);
        background: var(--bg-card);
        box-shadow: var(--shadow-sm);
    }

    .bids-row--best {
        border-color: var(--focus-ring);
        box-shadow: 0 0 0 1px var(--focus-ring);
    }

    .bids-row--best td:first-child {
        box-shadow: none;
    }

    .bids-table tbody td {
        padding: var(--space-2) 0;
        border-bottom: 1px dashed var(--border-color-thin);
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .bids-table tbody td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .bids-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.78em;
        flex: 0 0 auto;
        min-width: 72px;
    }

    .bids-msg {
        max-width: none;
        text-align: right;
    }

    .bids-action {
        justify-content: flex-end;
    }
}
@media (prefers-reduced-motion: reduce) {
    .list-card--skeleton .sk::after {
        animation: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    input.field-valid-flash,
    textarea.field-valid-flash,
    select.field-valid-flash {
        transition: none;
    }
}
@media (max-width: 640px) {
    .maker-storefront__title {
        font-size: 1.2rem;
    }

    .maker-storefront__products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .portfolio-grid--public {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .mp-cal-wrap { margin: 0 -8px; padding: 0 8px 8px; }
    .mp-cal { min-width: 640px; }
    .mp-cards-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ЭТАП 1 — МОБИЛЬНАЯ НАВИГАЦИЯ (<1024px, десктоп не трогаем)
   ============================================================ */
@media (max-width: 1023px) {
    :root {
        --mobile-tab-bar-h: 56px;
    }

    /* Нижняя таб-панель */
    .mobile-tab-bar {
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 220;
        min-height: var(--mobile-tab-bar-h);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: color-mix(in srgb, var(--bg-card) 94%, transparent);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--border-color-thin);
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
    }

    [data-theme="dark"] .mobile-tab-bar {
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
    }

    .mobile-tab {
        flex: 1 1 0;
        /* ВАЖНО: width:auto перебивает глобальное button{width:100%} из components.css.
           Без этого у .mobile-tab--center (flex-basis:auto) базовый размер = 100% ширины,
           центральная кнопка занимает ВСЮ панель, а остальные вкладки сжимаются в ноль. */
        width: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        min-height: 44px;
        margin: 0;
        padding: 6px 2px 4px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 600;
        line-height: 1.1;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.2s ease;
    }

    .mobile-tab__icon {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-tab__label {
        font-size: 11px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-tab.active {
        color: var(--text-main);
    }

    .mobile-tab-icon-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
    }

    .mobile-tab-badge {
        display: none;
        position: absolute;
        top: -2px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: var(--danger, #e53935);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        line-height: 18px;
        text-align: center;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .mobile-tab--center {
        flex: 0 0 auto;
        min-width: 72px;
        margin-top: -18px;
        padding-top: 0;
        color: var(--text-main);
    }

    .mobile-tab-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--text-main);
        color: var(--bg-card);
        font-size: 26px;
        font-weight: 400;
        line-height: 1;
        box-shadow: 0 6px 20px var(--fab-shadow);
    }

    .mobile-tab--center .mobile-tab__label {
        margin-top: 2px;
    }

    /* FAB скрыты — функции в таб-панели */
    .fab {
        display: none !important;
    }

    /* Отступы контента под фикс. шапку и таб-бар */
    body {
        padding-top: calc(var(--mobile-header-h, 56px) + env(safe-area-inset-top, 0px));
        padding-bottom: calc(var(--mobile-tab-h, 56px) + env(safe-area-inset-bottom, 0px));
    }

    /* Шапка: одна строка, уезжает при скролле вниз */
    .site-header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 210;
        margin: 0 !important;
        padding: env(safe-area-inset-top, 0px) 0 0 !important;
        background: color-mix(in srgb, var(--bg-main) 96%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        transform: translateY(0);
        transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    .site-header.site-header--hidden {
        transform: translateY(-100%);
        box-shadow: none !important;
    }

    .site-header.scrolled {
        box-shadow: var(--shadow-md, 0 4px 16px rgba(15, 23, 42, 0.1));
    }

    .site-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0;
    }

    .container.header {
        flex: 1 1 auto;
        min-width: 0;
        flex-wrap: nowrap;      /* перебиваем wrap из блока ≤768: тема не уезжает на 2-ю строку */
        margin-bottom: 0 !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        border-bottom: none !important;
        background: transparent !important;
    }

    .logo-container {
        font-size: 1em;
        gap: 8px;
        flex: 1 1 auto;
        min-width: 0;
    }

    .logo-container .icon {
        width: 24px;
        height: 24px;
    }

    .logo-container svg + text,
    .logo-container {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* На мобиле в шапке только лого + тема; вход/продавец — через таб «Кабинет» */
    #becomeSellerBtn,
    #userMenu {
        display: none !important;
    }

    .header-right-block {
        gap: 4px !important;
        margin-left: auto !important;
    }

    .header-right-block .theme-toggle {
        width: 44px;            /* глобальное button{width:100%} растягивало кнопку темы */
        flex: 0 0 auto;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        margin: 0;
    }

    /* Верхние вкладки скрыты; уведомления остаются в строке шапки */
    .nav-tabs {
        flex: 0 0 auto;
        /* ВАЖНО: .nav-tabs — это ещё и .container, который на ≤768 получает width:100%.
           С flex-basis:auto и запретом сжатия он занимал ВСЮ шапку и выдавливал
           блок лого+тема в ноль (лого и тема торчали обрезками у левого края). */
        width: auto !important;
        max-width: none;
        display: flex !important;
        align-items: center;
        margin: 0 !important;
        padding: 8px 10px 8px 0 !important;
        border: none !important;
        background: transparent !important;
        overflow: visible !important;
        position: static !important;
    }

    .nav-tab,
    #cartNavBtn,
    .nav-tabs > .header-btn[onclick*="openFeedback"] {
        display: none !important;
    }

    #notifBtn {
        display: inline-flex !important;
        width: auto;            /* глобальное button{width:100%} раздувало колокольчик
                                   на всю ширину и выдавливало лого с темой из шапки */
        flex: 0 0 auto;
        min-width: 44px;
        min-height: 44px;
        margin: 0 !important;
        padding: 0 10px !important;
        border-radius: 999px;
    }

    /* Тосты над таб-панелью */
    .toast-root {
        bottom: calc(var(--mobile-tab-h, 56px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
    }
}

@media (min-width: 1024px) {
    .mobile-tab-bar {
        display: none !important;
    }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
    .site-header {
        transition: none;
    }

    .mobile-tab {
        transition: none;
    }
}

/* ============================================================
   ЭТАП 2 — МОДАЛКИ → BOTTOM SHEET (<1024px)
   ============================================================ */
@keyframes sheetSlideUp {
    from { transform: translateY(100%); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1023px) {
    .modal,
    .materials-modal {
        align-items: flex-end !important;
        justify-content: flex-end !important;
        padding: 0 !important;
        overflow: hidden;
    }

    .modal[style*="display: block"],
    .materials-modal[style*="display: block"] {
        display: flex !important;
    }

    .modal-content,
    .materials-modal-content,
    #authModal .auth-card {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        max-height: 92dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        border-radius: 16px 16px 0 0 !important;
        border-bottom: none;
        padding: 28px 18px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
        animation: sheetSlideUp 0.25s ease;
        touch-action: pan-y;
    }

    .modal-content::before,
    .materials-modal-content::before,
    #authModal .auth-card::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        margin: -16px auto 14px;
        border-radius: 999px;
        background: var(--border-color);
        flex-shrink: 0;
    }

    .modal-content.sheet-dragging,
    .materials-modal-content.sheet-dragging,
    #authModal .auth-card.sheet-dragging {
        animation: none;
        transition: none;
    }

    .close-btn {
        top: 18px !important;
        right: 14px !important;
        z-index: 2;
    }

    #productModal .modal-content {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #confirmModal .modal-content {
        max-height: 50dvh;
    }

    /* Подтверждение — поверх всего, включая sticky-бар покупки (z-1005) */
    #confirmModal {
        z-index: 1300;
    }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
    .modal-content,
    .materials-modal-content,
    #authModal .auth-card {
        animation: none;
    }
}

/* ============================================================
   ЭТАП 3 — КАТАЛОГ И ТОВАР (<768px)
   ============================================================ */
@media (max-width: 767px) {
    .catalog-filters-btn {
        display: inline-flex !important;
        min-height: 44px;
        align-items: center;
    }

    .catalog-side {
        display: none;
    }

    body.catalog-filters-open .catalog-filters-backdrop {
        display: block;
    }

    body.catalog-filters-open .catalog-side {
        display: block;
        position: fixed;
        /* К самому низу экрана, ПОВЕРХ таб-бара (z 235 > 220) — как все шторки.
           Раньше bottom: var(--mobile-tab-h) — JS-переменная давала мусорное
           значение и панель зависала посреди экрана. Никаких var в позиции. */
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 235;
        max-height: min(80dvh, calc(100dvh - var(--mobile-header-h, 56px) - 12px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-card);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.15);
        animation: sheetSlideUp 0.25s ease;
    }

    .catalog-filters-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 230;
        background: var(--overlay-scrim);
        backdrop-filter: blur(2px);
    }

    .catalog-filter-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 10px;
    }

    .catalog-filter-chips:empty {
        display: none;
    }

    .catalog-filter-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 10px;
        border-radius: 999px;
        border: 1px solid var(--border-color-thin);
        background: var(--bg-card);
        font-size: 12px;
        font-weight: 600;
        color: var(--text-main);
        cursor: pointer;
        min-height: 32px;
    }

    .catalog-filter-chip__x {
        opacity: 0.6;
        font-size: 14px;
        line-height: 1;
    }

    .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .product-card {
        padding: 10px !important;
    }

    .product-image-placeholder {
        aspect-ratio: 1 / 1;
        margin-bottom: 8px !important;
    }

    .product-title {
        font-size: 0.88em !important;
        line-height: 1.25;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        min-height: 2.5em;
    }

    .product-price {
        font-size: 1.15em !important;
        font-weight: 700;
        margin-top: 4px;
    }

    .product-card button {
        width: 100% !important;
        min-height: 44px !important;
        margin-top: 8px !important;
        font-size: 0.85em !important;
    }

    .product-details-gallery {
        margin: 0 -18px 12px;
        width: calc(100% + 36px);
    }

    .product-details-gallery .product-details-img {
        border-radius: 0;
        margin: 0;
    }

    .detail-gallery-dots {
        display: flex;
        justify-content: center;
        gap: 6px;
        margin: -6px 0 12px;
    }

    .detail-gallery-dots:empty {
        display: none;
    }

    .detail-gallery-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        border: none;
        padding: 0;
        background: var(--border-color);
        cursor: pointer;
    }

    .detail-gallery-dot.active {
        background: var(--text-main);
        transform: scale(1.15);
    }

    #productModal #detailBuyBtn {
        display: none !important;
    }

    #productModal #detailBuyBtn + .safe-deal-note {
        display: none !important;
    }

    .detail-sticky-bar {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        /* absolute к #productModal (fixed на весь экран), НЕ fixed:
           внутри шторки fixed цеплялся за скроллер и уплывал с контентом */
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1005;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
        background: color-mix(in srgb, var(--bg-card) 96%, transparent);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-color-thin);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.1);
    }

    .detail-sticky-bar__price {
        flex: 1 1 auto;
        font-size: 1.2em;
        font-weight: 700;
        min-width: 0;
    }

    .detail-sticky-bar__actions {
        display: flex;
        gap: 8px;
        flex: 0 0 auto;
    }

    .detail-sticky-bar__ar {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        border: 1px solid var(--border-color-thin);
        background: var(--bg-main);
        font-size: 1.2em;
        cursor: pointer;
        flex: 0 0 auto;
    }

    .detail-sticky-bar__buy {
        min-height: 44px !important;
        min-width: 120px;
        width: auto !important;
        padding: 0 18px !important;
        white-space: nowrap;
    }

    #detailArBtn.ar-open-btn {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .detail-sticky-bar {
        display: none !important;
    }

    .catalog-filters-btn {
        display: none !important;
    }
}

/* ============================================================
   ЭТАП 4 — ФОРМЫ И КАБИНЕТ (<768px)
   ============================================================ */
@media (max-width: 767px) {
    .form-card label,
    .form-card .field > span,
    .modal-content label,
    .collapsible-filters label {
        display: block;
        font-size: 0.88em;
        font-weight: 600;
        margin-bottom: 4px;
        color: var(--text-muted);
    }

    .form-card .grid,
    .form-grid-2,
    .collapsible-filters .grid {
        grid-template-columns: 1fr !important;
    }

    .form-card input,
    .form-card select,
    .form-card textarea,
    .modal-content > input,
    .modal-content > select,
    .modal-content > textarea,
    .collapsible-filters input,
    .collapsible-filters select,
    .collapsible-filters textarea {
        width: 100%;
        margin-bottom: 12px !important;
    }

    .form-card .btn-black,
    .form-card button[type="submit"],
    .modal-content > .btn-black:last-of-type {
        width: 100%;
        min-height: 48px;
    }

    .cabinet-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 8px !important;
        padding-bottom: 4px;
        margin-bottom: 14px !important;
    }

    .cabinet-tab {
        scroll-snap-align: start;
        flex: 0 0 auto;
    }

    .bids-table thead {
        display: none;
    }

    .bids-table,
    .bids-table tbody,
    .bids-table tr,
    .bids-table td {
        display: block;
        width: 100%;
    }

    .bids-table tbody tr {
        margin-bottom: var(--space-3);
        padding: var(--space-3);
        border: 1px solid var(--border-color-thin);
        border-radius: var(--radius-md);
        background: var(--bg-card);
    }

    .bids-table tbody td {
        padding: var(--space-2) 0;
        border-bottom: 1px dashed var(--border-color-thin);
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .bids-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.78em;
        flex: 0 0 auto;
        min-width: 72px;
    }

    .mp-cal-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mp-cal-label {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--bg-card);
        box-shadow: 4px 0 8px rgba(15, 23, 42, 0.04);
    }
}

/* ============================================================
   ЭТАП 5 — ФИНАЛЬНЫЙ АУДИТ МОБИЛЫ (<1024px)
   ============================================================ */
@media (max-width: 1023px) {
    html {
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .content-section,
    .container,
    .catalog-layout,
    .search-filters-container {
        max-width: 100%;
        overflow-x: clip;
    }

    img, video, canvas, svg {
        max-width: 100%;
        height: auto;
    }

    /* Футер НЕ дублирует отступ под таб-бар: body уже имеет
       padding-bottom: var(--mobile-tab-h) (этап 1) — иначе внизу страницы
       возникала мёртвая зона ~112px. */
}

@media (max-width: 767px) {
    .mobile-tab__label,
    .catalog-filter-chip {
        font-size: 11px;
    }
}

@media (min-width: 1024px) {
    .detail-sticky-bar,
    .catalog-filters-backdrop,
    .catalog-filter-chips {
        display: none !important;
    }
}

