/* QDizer mobile closure v1 — final responsive polish for public + authenticated shells. */

/* Never expose internal implementation notes to customers. */
.screenshot-replace-note {
    display: none !important;
}

@media (max-width: 767px) {
    /* Public homepage: keep proof points orderly instead of free-wrapping. */
    .micro-proof {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px 14px !important;
        align-items: start !important;
    }

    .micro-proof > span {
        min-width: 0;
        line-height: 1.35;
    }

    /* Public mobile navigation: preserve generous touch targets without wasting a full screen. */
    .nav-inner.open .nav-links {
        gap: 0 !important;
        padding-top: 14px !important;
        padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    }

    .nav-inner.open .nav-links > a {
        padding-top: 13px !important;
        padding-bottom: 13px !important;
    }

    .nav-inner.open .mobile-auth-actions {
        margin-top: 8px !important;
        padding-top: 14px !important;
    }

    /* Hero/problem headings: prevent awkward four/five-line wraps on 360–390px phones. */
    .hero h1 {
        font-size: clamp(42px, 13.4vw, 58px) !important;
        line-height: 1.01 !important;
    }

    .problem h2,
    .section.problem h2 {
        font-size: clamp(38px, 11.5vw, 50px) !important;
        line-height: 1.02 !important;
        text-wrap: balance;
    }

    /* PDF modal: viewport-contained shell; embedded viewer is forced to mobile fit mode by JS. */
    .template-modal,
    .template-modal-panel,
    .template-modal-card {
        max-width: 100vw !important;
    }

    .template-modal-panel,
    .template-modal-card {
        width: calc(100vw - 16px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .template-modal-canvas,
    .template-pdf-canvas {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .template-pdf-frame {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        border: 0 !important;
    }

    .template-modal-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    /* Public back-to-top: smaller and clear of iOS/Safari bottom UI. */
    .back-to-top {
        width: 50px !important;
        height: 50px !important;
        right: 14px !important;
        bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    }

    /* Authenticated help bubble: keep it off cards and above mobile browser chrome. */
    .qd-help-float {
        right: 12px !important;
        bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    }

    .qd-help-float-link {
        min-height: 46px;
        padding: 8px 13px 8px 8px !important;
        box-shadow: 0 12px 28px rgba(8, 31, 42, .20) !important;
    }

    /* Authenticated sidebar: dynamic viewport + safe area, with footer/account always reachable. */
    #sidebar.sidebar {
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        padding-bottom: calc(92px + env(safe-area-inset-bottom)) !important;
        -webkit-overflow-scrolling: touch;
    }

    #sidebar .sidebar-footer {
        flex-shrink: 0;
    }

    #sidebar .user-dropdown-btn {
        margin-bottom: env(safe-area-inset-bottom) !important;
    }

    /* Quotation builder: services become a real step before notes/totals/generate. */
    [data-qd-mobile-services="true"] {
        margin: 18px 0 20px !important;
        padding: 18px 0 !important;
        border: 0 !important;
        border-top: 1px solid #e2ded4 !important;
        border-bottom: 1px solid #e2ded4 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    [data-qd-mobile-services="true"] h5 {
        font-size: 1.15rem;
        margin-bottom: 14px !important;
    }

    [data-qd-mobile-services="true"] .table-responsive {
        overflow: visible !important;
    }

    [data-qd-mobile-services="true"] table,
    [data-qd-mobile-services="true"] tbody,
    [data-qd-mobile-services="true"] tr,
    [data-qd-mobile-services="true"] td {
        display: block;
        width: 100% !important;
    }

    [data-qd-mobile-services="true"] thead {
        display: none;
    }

    [data-qd-mobile-services="true"] tr {
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid #e2ded4;
        border-radius: 14px;
        background: #fff;
    }

    [data-qd-mobile-services="true"] td {
        padding: 5px 0 !important;
        border: 0 !important;
    }

    .qd-mobile-service-empty {
        display: grid;
        gap: 8px;
        padding: 15px;
        margin-bottom: 14px;
        border: 1px solid #ecd39e;
        border-radius: 14px;
        background: #fff8e8;
    }

    .qd-mobile-service-empty strong {
        color: #17343f;
    }

    .qd-mobile-service-empty span {
        color: #68767d;
        font-size: .9rem;
    }

    .qd-mobile-service-empty .btn {
        justify-self: start;
        margin-top: 2px;
    }
}

@media (max-width: 390px) {
    .hero h1 {
        font-size: clamp(40px, 12.8vw, 50px) !important;
    }

    .problem h2,
    .section.problem h2 {
        font-size: clamp(36px, 10.8vw, 44px) !important;
    }
}