/* Мобильная оболочка (≤768px): навигация как в приложении, палитра как на десктопе */

@media (max-width: 768px) {
    :root {
        --app-mobile-logo-h: 56px;
        --app-top-bar-h: 74px;
        --home-search-submit-h: 41px;
        --app-mobile-radius: var(--radius);
    }

    .app-header__desktop-only {
        display: none !important;
    }

    .app-header__mobile-only {
        display: block !important;
    }

    .app-header__mobile-only.app-header__mobile-bar {
        display: flex !important;
    }

    html {
        color-scheme: only light;
    }

    body.app-shell {
        background-color: var(--bg) !important;
        color: var(--text) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        -webkit-tap-highlight-color: rgba(2, 141, 164, .15);
    }

    /* Палитра 1:1 с десктопом — без тёмных системных стилей полей и карточек */
    .app-shell .card,
    .app-shell .card--flat,
    .app-shell .catalog-filters-wrap__summary,
    .app-shell .vac-search-toolbar,
    .app-shell .alert,
    .app-shell dialog.modal,
    .app-shell .app-drawer__panel {
        background-color: var(--surface) !important;
        color: var(--text) !important;
    }

    .app-shell .input,
    .app-shell .select,
    .app-shell .textarea,
    .app-shell .home-search-panel__input {
        background-color: var(--surface) !important;
        color: var(--text) !important;
        border: 1px solid var(--border-strong) !important;
        -webkit-text-fill-color: var(--text) !important;
    }

    .app-shell .select option {
        background-color: var(--surface);
        color: var(--text);
    }

    .app-shell .input::placeholder {
        color: var(--text-muted) !important;
        opacity: 1;
    }

    .app-shell .input:-webkit-autofill,
    .app-shell .input:-webkit-autofill:hover,
    .app-shell .input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
        -webkit-text-fill-color: var(--text) !important;
        caret-color: var(--text);
    }

    body.app-drawer-open {
        overflow: hidden;
    }

    /* ---------- Шапка: бургер · лого · войти (одна строка, фикс. высота) ---------- */

    .app-header {
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: var(--shadow-sm);
        font-size: var(--fs-14);
        line-height: 1;
        overflow: hidden;
    }

    /* Сброс десктопных переносов шапки (app.css ≤640px) */
    .app-header__row {
        height: var(--app-top-bar-h) !important;
        min-height: var(--app-top-bar-h) !important;
        max-height: var(--app-top-bar-h) !important;
        padding: 0 !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        align-items: center !important;
        overflow: hidden;
    }

    .app-header__left,
    .app-header__right {
        flex: none !important;
        width: auto !important;
    }

    .app-header .container.app-header__row {
        height: 100%;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .app-header__mobile-only.app-header__mobile-bar,
    .app-header__mobile-bar {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-start;
        gap: 0;
        box-sizing: border-box;
        width: 100%;
        height: var(--app-top-bar-h);
        max-height: var(--app-top-bar-h);
        padding-left: 8px !important;
        padding-right: 24px !important;
        line-height: 1;
    }

    .app-header .app-drawer-toggle {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        box-sizing: border-box;
        width: auto;
        min-width: 0;
        height: 44px;
        margin: 0 6px 0 0 !important;
        padding: 0 0 0 7px;
        border: none;
        border-radius: 0;
        background: transparent;
        color: var(--text-on-dark);
        cursor: pointer;
    }

    .app-header .app-drawer-toggle svg {
        display: block;
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .app-header .app-drawer-toggle:hover {
        background: rgba(255, 255, 255, .16);
    }

    .app-header .brand--mobile {
        flex: 0 1 auto;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-width: 0;
        height: var(--app-mobile-logo-h);
        max-height: var(--app-mobile-logo-h);
        margin: 0;
        padding: 0;
        line-height: 0;
        overflow: hidden;
    }

    .app-header .brand--mobile .brand__logo {
        display: block;
        height: var(--app-mobile-logo-h) !important;
        max-height: var(--app-mobile-logo-h) !important;
        width: auto !important;
        max-width: min(240px, 48vw) !important;
        margin: 0;
        object-fit: contain;
        object-position: center center;
    }

    .app-header .brand--mobile .brand__mark {
        width: var(--app-mobile-logo-h) !important;
        height: var(--app-mobile-logo-h) !important;
    }

    .app-header__city-link--mobile {
        flex: 0 1 auto;
        min-width: 0;
        max-width: 28vw;
        margin: 0 4px 0 0;
        padding: 8px 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: calc(var(--fs-14) * 1.1);
        color: var(--text-on-dark);
        text-decoration: none;
        border-bottom: 2px solid transparent;
    }

    .app-header__city-link--mobile:hover {
        color: #fff;
        border-bottom-color: rgba(255, 255, 255, .75);
        text-decoration: none;
    }

    .app-header__mobile-actions {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        align-self: center;
        margin-left: auto;
        padding-right: 0;
        line-height: 1;
    }

    .app-header__login-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: auto;
        min-height: 0;
        margin: 0;
        padding: 8px 0;
        border: none;
        border-radius: 0;
        border-bottom: 2px solid transparent;
        background: transparent;
        color: var(--text-on-dark);
        font-family: inherit;
        font-size: calc(var(--fs-14) * 1.2);
        font-weight: inherit;
        line-height: inherit;
        letter-spacing: normal;
        text-decoration: none;
        cursor: pointer;
        white-space: nowrap;
        transition: color .12s ease, border-color .12s ease;
    }

    .app-header__login-btn:hover {
        color: #fff;
        background: transparent;
        border-bottom-color: rgba(255, 255, 255, .75);
        text-decoration: none;
    }

    /* ---------- Боковое меню (drawer) ---------- */

    .app-drawer {
        position: fixed;
        inset: 0;
        z-index: 300;
        pointer-events: none;
        visibility: hidden;
    }

    .app-drawer.is-open {
        pointer-events: auto;
        visibility: visible;
    }

    .app-drawer__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        opacity: 0;
        transition: opacity .2s ease;
    }

    .app-drawer.is-open .app-drawer__backdrop {
        opacity: 1;
    }

    .app-drawer__panel {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, calc(100vw - 48px));
        max-width: 100%;
        padding: 12px 0 24px;
        background: var(--surface);
        color: var(--text);
        box-shadow: var(--shadow);
        transform: translateX(-100%);
        transition: transform .22s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-drawer.is-open .app-drawer__panel {
        transform: translateX(0);
    }

    .app-drawer__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px 12px;
        border-bottom: 1px solid var(--border);
    }

    .app-drawer__title {
        font-family: var(--font-accent);
        font-size: var(--fs-22);
        letter-spacing: 0.03em;
    }

    .app-drawer__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--text-muted);
        cursor: pointer;
    }

    .app-drawer__list {
        list-style: none;
        margin: 0;
        padding: 8px 0;
    }

    .app-drawer__list > li {
        margin: 0;
    }

    .app-drawer__link {
        display: block;
        padding: 14px 20px;
        color: var(--text);
        font-size: var(--fs-16);
        text-decoration: none;
    }

    .app-drawer__link:hover,
    .app-drawer__link.is-active {
        background: var(--brand-soft);
        color: var(--brand-hover);
    }

    .app-drawer__sub {
        border-bottom: 1px solid var(--border);
    }

    .app-drawer__summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        font-size: var(--fs-16);
        font-weight: 500;
        color: var(--text);
        cursor: pointer;
        list-style: none;
    }

    .app-drawer__summary::-webkit-details-marker {
        display: none;
    }

    .app-drawer__summary::after {
        content: "▾";
        color: var(--text-muted);
        font-size: 14px;
        transition: transform .15s ease;
    }

    .app-drawer__sub[open] .app-drawer__summary::after {
        transform: rotate(180deg);
    }

    .app-drawer__subpanel {
        padding: 0 0 8px 12px;
        background: var(--surface-alt);
    }

    .app-drawer__sublink {
        display: block;
        padding: 10px 20px;
        color: var(--text-muted);
        font-size: var(--fs-14);
        text-decoration: none;
    }

    .app-drawer__sublink:hover,
    .app-drawer__sublink.is-active {
        color: var(--brand);
        background: var(--brand-soft);
    }

    .app-drawer__logout {
        margin: 16px 16px 0;
        padding-top: 16px;
        border-top: 1px solid var(--border);
    }

    /* ---------- Контент ---------- */

    main.app-main {
        padding: 12px 0 20px;
    }

    main.app-main > .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .app-footer {
        display: none;
    }

    .scroll-top-rail {
        display: none !important;
    }

    .card {
        border-radius: var(--radius-lg);
        padding: 16px 18px;
        margin-bottom: 12px;
        border: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
    }

    .cards-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .cards-grid .card,
    .vacancies-results > .card {
        margin: 0;
    }

    .card__title {
        font-size: var(--fs-18);
        line-height: 1.3;
    }

    .card__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .page-title {
        font-size: var(--fs-22);
        margin-bottom: 12px;
        line-height: 1.2;
    }

    .btn {
        min-height: 46px;
        letter-spacing: normal;
    }

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

    /* Каталог */

    .layout-2col {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .catalog-filters-wrap {
        display: block;
        margin-bottom: 0;
    }

    .catalog-filters-wrap__summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        list-style: none;
        cursor: pointer;
        padding: 14px 16px;
        border-radius: var(--radius-lg);
        background: var(--surface);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
        font-size: var(--fs-16);
        font-weight: 500;
        color: var(--text);
        margin-bottom: 8px;
    }

    .catalog-filters-wrap__summary::-webkit-details-marker {
        display: none;
    }

    .catalog-filters-wrap__summary::after {
        content: "▾";
        color: var(--text-muted);
    }

    .catalog-filters-wrap[open] .catalog-filters-wrap__summary::after {
        transform: rotate(180deg);
    }

    .vacancies-results {
        min-width: 0;
    }

    .vac-search-toolbar {
        position: static;
        z-index: auto;
        margin-bottom: 4px;
    }

    .vac-search-toolbar__actions {
        gap: 8px;
    }

    .vac-search-toolbar__actions .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        white-space: normal;
        text-align: center;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Главная — как на десктопе: без тёмной/объёмной обёртки формы */

    .page-home-minimal {
        background: var(--bg) !important;
    }

    .page-home-minimal .home-search-panel {
        padding: 20px 0 12px;
    }

    .page-home-minimal .home-search-panel .page-title {
        font-size: var(--fs-22);
        margin-bottom: 24px;
    }

    .home-search-panel__form {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 0;
        padding: 0;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    .page-home-minimal .home-search-panel__form .input.home-search-panel__input,
    .app-shell .home-search-panel__input.input {
        min-width: 0;
        max-width: none;
        width: 100%;
        height: calc(var(--home-search-submit-h) * 1.2) !important;
        min-height: calc(var(--home-search-submit-h) * 1.2) !important;
        max-height: none;
        padding: 0 20px !important;
        font-size: var(--fs-16);
        border-radius: 999px;
        line-height: 1.2;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .home-search-panel__submit.btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: auto;
        max-width: 200px;
        min-height: var(--home-search-submit-h);
        height: var(--home-search-submit-h);
        padding: 5px 28px 0;
        margin: 0 auto;
        align-self: center;
        font-family: var(--font-accent);
        font-size: var(--fs-18);
        font-weight: 500;
        line-height: 1;
        letter-spacing: 0.04em;
        text-align: center;
        border-radius: 999px;
    }

    .home-search-panel__foot {
        margin-top: 12px;
        font-size: var(--fs-14);
        line-height: 1.55;
    }

    .home-search-panel__foot a {
        color: var(--text-muted);
    }

    .home-recent__head .page-title {
        font-size: var(--fs-18);
    }

    /* Кабинет */

    .seeker-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        margin-bottom: 12px;
        border-radius: var(--radius-lg);
        background: var(--surface-alt);
        border: 1px solid var(--border);
        scrollbar-width: none;
    }

    .seeker-tabs::-webkit-scrollbar {
        display: none;
    }

    .seeker-tabs a {
        flex: 1 0 auto;
        padding: 12px 14px;
        font-size: var(--fs-14);
        border-bottom: 2px solid transparent;
        white-space: nowrap;
    }

    .seeker-tabs a.is-active {
        background: var(--surface);
        border-bottom-color: var(--brand);
        color: var(--brand);
    }

    .app-shell .card.stack[style*="max-width"] {
        max-width: none !important;
    }

    dialog.modal {
        max-width: min(440px, calc(100vw - 24px));
        width: 100%;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .stack > * + * {
        margin-top: 12px;
    }

    .row {
        gap: 8px;
    }
}

@media (min-width: 769px) {
    .app-header__mobile-only {
        display: none !important;
    }

    .app-drawer {
        display: none !important;
    }

    body.app-shell {
        padding-bottom: 0;
    }

    .catalog-filters-wrap > summary {
        display: none;
    }

    .catalog-filters-wrap {
        display: contents;
    }
}
