/* Shared layout for mobile browsers and the Telegram WebView. */
:root {
    --box-safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
    --box-safe-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
    --box-safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
    --box-safe-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
    --box-viewport-height: 100vh;
}
@supports (height: 100dvh) {
    :root { --box-viewport-height: 100dvh; }
}

.box-mobile-actions { display: none; }

@media (max-width: 996px) {
    html { scroll-padding-top: calc(60px + var(--box-safe-top)); }
    body.nav-fixed { padding-bottom: var(--box-safe-bottom); }
    body.nav-fixed > main {
        max-inline-size: 100%;
        padding-inline: var(--box-safe-left) var(--box-safe-right);
    }

    .header.header-layout-1.box-compact-header {
        height: auto;
        padding: var(--box-safe-top) max(8px, var(--box-safe-right)) 0 max(8px, var(--box-safe-left));
    }
    .box-compact-header .container-header {
        width: 100%;
        padding: 0;
    }
    .box-compact-header .navbar-header {
        float: none;
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 52px;
        margin: 0;
    }
    .box-compact-header :is(.navbar-header, .container-header)::before,
    .box-compact-header :is(.navbar-header, .container-header)::after {
        display: none;
    }
    .box-compact-header .navbar-collapse { display: none !important; }
    .box-compact-header .navbar-toggle {
        display: inline-flex;
        flex: 0 0 44px;
        align-items: center;
        justify-content: center;
        order: -1;
        width: 44px;
        height: 44px;
        margin: 0;
        padding: 0;
    }
    .box-compact-header .navbar-top.center .navbar-brand {
        position: static;
        width: auto;
        float: none;
        display: flex;
        flex: 1 1 auto;
        align-items: center;
        justify-content: center;
        min-width: 0;
        height: auto;
        margin: 0;
        padding: 0;
    }
    .box-compact-header .navbar-logo { display: block; max-width: 100%; }
    .box-compact-header .navbar-logo > img {
        display: block;
        width: auto;
        height: auto;
        max-width: min(100%, 148px);
        max-height: 32px;
        padding: 0;
    }

    .box-mobile-actions {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        gap: 4px;
    }
    .box-mobile-actions > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        padding: 0 8px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 700;
        white-space: nowrap;
        touch-action: manipulation;
    }
    .box-mobile-actions > a:first-child {
        background: #ffbf72;
        color: #281b29;
    }

    .mobile-header > .mobile-navbar.box-compact-drawer {
        position: fixed;
        z-index: 997;
        display: block !important;
        top: 0;
        bottom: 0;
        left: 0;
        box-sizing: border-box;
        width: min(300px, calc(100vw - 36px));
        height: auto;
        max-height: min(var(--box-viewport-height), var(--tg-viewport-stable-height, var(--box-viewport-height)));
        padding: calc(64px + var(--box-safe-top)) 10px calc(12px + var(--box-safe-bottom)) max(10px, var(--box-safe-left)) !important;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .mobile-header > .box-compact-drawer:not(.show) {
        visibility: hidden;
        transform: translateX(-110%);
    }
    .mobile-header > .box-compact-drawer.show {
        visibility: visible;
        transform: none;
    }
    .mobile-header > .box-compact-drawer.show ~ .fixed-body {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        touch-action: none;
    }
    .box-compact-drawer .mobile-menus a {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-height: 44px;
    }

    .nav-fixed :is(.history-toast, .float-right.position-bottom) {
        bottom: calc(12px + var(--box-safe-bottom));
    }
    #mywork-page .history-bulk-bar { bottom: calc(8px + var(--box-safe-bottom)); }
    .nav-fixed .drawer-sm { padding-bottom: var(--box-safe-bottom); }
}

@media (max-width: 767px) {
    .article :is(.zib-app, .nude2-app) .main-container > * { min-width: 0; }
    :is(.article, .user-center, .modal) :is(textarea, select, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="tel"], input[type="search"], input[type="url"], input[type="date"]) {
        min-width: 0;
        max-width: 100%;
        font-size: 16px !important;
    }
    .article .nude2-app.zib-app :is(.prompt-field, .prompt-field.prompt-negative-full) textarea {
        font-size: 16px !important;
    }
    .zib-queue-actions button,
    .user-center :is([data-user-asset-panel], [data-web-plan], [data-web-channel], [data-web-payment-submit], [data-web-order-refresh]),
    #mywork-page.nude2-app :is(.task-actions .btn, .task .task-actions .btn.jb-purple:not(:disabled), .btn-extra-row .btn) {
        min-height: 44px;
        white-space: normal;
        touch-action: manipulation;
    }
    .user-center [data-web-pay-actions] { flex-wrap: wrap; }
    .user-center-content[data-payment-open] { scroll-margin-top: 12px; }

    .article .nude2-app .warning-modal-content {
        max-height: min(calc(var(--box-viewport-height) - 32px), calc(var(--tg-viewport-stable-height, var(--box-viewport-height)) - var(--box-safe-top) - var(--box-safe-bottom) - 32px));
        overflow-y: auto;
    }
}
