/* Phone layout. The desktop stage uses a sized container that collapses
   when the page is not a fixed two-column viewport, which hid the device. */

@media (max-width: 900px) {
    html,
    body {
        height: 100%;
        overflow: hidden;
    }

    body {
        height: 100dvh;
        padding: 0;
    }

    .container {
        height: auto;
        min-height: 0;
        overflow: hidden;
    }

    .header {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    }

    .header h1 {
        flex: 1;
        min-width: 0;
        font-size: 1.05rem;
    }

    .header p {
        display: none;
    }

    .header-tools {
        margin: 0 0 0 auto;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .header-tool {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .main-content {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
        overflow: hidden;
    }

    .preview-section {
        order: -1;
        flex: none;
        position: relative;
        width: 100%;
        max-height: none;
        overflow: visible;
        align-items: center;
        padding: 8px 12px 10px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .preview-stage {
        flex: none;
        width: 100%;
        min-height: 0;
        overflow: visible;
    }

    .preview-section h2 {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .preview-section .knomi-preview {
        container-type: normal;
        contain: none;
        display: flex;
        flex: none;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
        align-items: center;
        justify-content: center;
    }

    .preview-section .device-frame {
        width: fit-content;
        max-width: 100%;
        height: auto;
        margin: 0 auto;
    }

    .preview-section .knomi-device {
        display: block;
        width: auto;
        height: auto;
        max-width: min(220px, 62vw);
        max-height: min(230px, 30dvh);
        filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.45));
    }

    .device-picker {
        margin-bottom: 4px;
    }

    .device-option {
        min-height: 40px;
        padding: 8px 14px;
    }

    .device-caption {
        margin-top: 4px;
    }

    .preview-scroll {
        width: 100%;
        overflow: visible;
        padding: 0;
    }

    .file-size-estimator {
        max-height: none;
        width: 100%;
        margin-top: 8px;
        overflow: visible;
    }

    .preview-dock {
        width: 100%;
    }

    .preview-dock:not(.is-idle) {
        margin-top: 8px;
        padding-top: 8px;
    }

    .upload-section {
        flex: 1;
        min-height: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        border-right: 0;
        padding: 12px 12px 20px;
    }

    .upload-section h2 {
        margin-bottom: 8px;
    }

    .upload-section .form-group {
        margin-bottom: 10px;
        padding: 10px 12px 12px;
    }

    #knomiInstall,
    #knomiConnectGroup,
    #knomiPushBtn,
    .knomi-push-help {
        display: none !important;
    }

    .form-group select,
    .search-input,
    .search-btn,
    .source-tab,
    .btn {
        min-height: 44px;
        font-size: 16px;
    }

    .source-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .search-input-group {
        flex-wrap: wrap;
    }

    .search-input {
        flex: 1 1 140px;
        min-width: 0;
    }

    .search-btn {
        flex: none;
    }

    .gif-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        max-height: 240px;
    }

    .upload-area {
        padding: 22px 12px;
    }

    .crop-row {
        gap: 8px;
    }

    .site-footer {
        flex: none;
        gap: 2px;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom)) !important;
    }

    .footer-note,
    .footer-legal {
        font-size: 0.68rem;
        line-height: 1.3;
    }

    .footer-links {
        gap: 10px;
        font-size: 0.78rem;
    }

    .install-banner:not([hidden]) {
        display: flex;
    }
}

html.is-ios .install-banner:not([hidden]) {
    display: flex;
}

html.is-standalone .install-banner {
    display: none !important;
}
