/* FlowPDF mobile layout layer — loaded last to resolve older responsive rules. */
@media (max-width: 760px) {
  html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    width: 100%;
    overflow-x: hidden;
  }

  body *,
  body *::before,
  body *::after {
    min-width: 0;
  }

  button,
  .uploadButton,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    max-width: 100%;
    font-size: 16px !important;
  }

  header {
    padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)) !important;
  }

  .topbar {
    flex-flow: row nowrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .brand {
    flex: 1 1 auto !important;
    gap: 0 !important;
  }

  .brand img.logo {
    width: 104px !important;
    height: 44px !important;
    max-width: 104px !important;
    max-height: 44px !important;
    flex: 0 0 104px !important;
    object-fit: contain;
  }

  .brandCopy,
  .flowPdfHeaderPrivacy {
    display: none !important;
  }

  .flowPdfHeaderAttribution {
    display: inline-flex !important;
    min-height: 40px !important;
    padding: 7px 8px !important;
    border-color: #bfdbfe !important;
    background: #eff6ff !important;
    color: #64748b !important;
    font-size: 9px !important;
    box-shadow: none !important;
  }

  .flowPdfHeaderAttribution strong {
    color: #1d4ed8 !important;
    font-size: 11px !important;
  }

  .headerRight {
    flex: 0 0 auto !important;
    width: auto !important;
    margin-left: auto !important;
    gap: 6px !important;
  }

  .flowPdfHeaderNav {
    gap: 6px !important;
  }

  .flowPdfHeaderTools,
  .headerRight #downloadBtn {
    min-width: 0 !important;
    min-height: 42px !important;
    padding: 9px 11px !important;
    border-radius: 13px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  body.hasPdf .flowPdfHeaderTools {
    display: none !important;
  }

  body.hasPdf .flowPdfHeaderAttribution {
    display: inline-flex !important;
  }

  .headerRight #downloadBtn {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.flowPdfHomeRedesign .layout {
    padding: 12px 10px 42px !important;
  }

  .flowPdfHome {
    gap: 14px;
  }

  .flowPdfHero,
  .flowPdfHeroCompact {
    padding: 26px 14px !important;
    border-radius: 22px;
  }

  .flowPdfEyebrow {
    font-size: 10px;
  }

  .flowPdfHero h1,
  .flowPdfHeroCompact h1 {
    margin-top: 16px !important;
    font-size: clamp(31px, 10vw, 40px) !important;
    letter-spacing: -.045em !important;
  }

  .flowPdfHeroLead {
    font-size: 14px;
    line-height: 1.55;
  }

  .flowPdfHeroDrop {
    margin-top: 20px;
    padding: 18px 12px;
    border-radius: 19px;
  }

  .flowPdfHeroChoose {
    display: flex !important;
    width: 100% !important;
    min-height: 48px !important;
  }

  .flowPdfTrustRow {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .flowPdfTrustRow::-webkit-scrollbar,
  .toolSwitch::-webkit-scrollbar,
  #sfstPageThumbs::-webkit-scrollbar,
  .sfstTools::-webkit-scrollbar,
  .sfstRibbon::-webkit-scrollbar,
  .quickDock::-webkit-scrollbar {
    display: none;
  }

  .flowPdfTrustRow span {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .flowPdfHomeFileBar {
    grid-template-columns: 42px minmax(0, 1fr) !important;
    gap: 10px;
    padding: 13px !important;
  }

  .flowPdfHomeFileIcon {
    width: 42px;
    height: 42px;
  }

  .flowPdfHomeFileAction {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 46px !important;
  }

  .flowPdfHomeSection {
    padding: 16px 12px !important;
    border-radius: 20px;
  }

  .flowPdfSectionHead {
    display: block;
    margin-bottom: 14px;
  }

  .flowPdfSectionHead h2 {
    font-size: 22px;
  }

  .flowPdfSectionHead .flowPdfTextButton {
    width: 100%;
    margin-top: 7px;
    padding: 8px 0 !important;
    text-align: left;
  }

  .flowPdfPopularGrid,
  .flowPdfCategoryGrid,
  .flowPdfDrawerGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
  }

  .flowPdfToolCard {
    min-height: 122px;
    padding: 13px !important;
  }

  .flowPdfCategoryTabs {
    margin-inline: -4px;
    scroll-snap-type: x mandatory;
  }

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

  .flowPdfHomePromo,
  .flowPdfMakerBar {
    gap: 14px;
    padding: 18px 16px !important;
  }

  .flowPdfHomePromo a,
  .flowPdfMakerLink {
    width: 100%;
  }

  .flowPdfToolsOverlay {
    align-items: flex-end;
    padding: 0 !important;
  }

  .flowPdfToolsDialog {
    width: 100%;
    max-height: calc(94dvh - env(safe-area-inset-top));
    padding: 16px 12px calc(20px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
  }

  .flowPdfToolsDialogHead {
    top: -16px;
  }

  body.flowPdfToolRedesign .layout {
    display: block !important;
    padding: 8px 8px calc(96px + env(safe-area-inset-bottom)) !important;
  }

  body.flowPdfToolRedesign .panel {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 0 8px !important;
    padding: 10px !important;
    border-radius: 18px !important;
  }

  body.flowPdfToolRedesign .panel > .section:first-child {
    padding-top: 0;
  }

  body.flowPdfToolRedesign .toolSwitch {
    display: flex !important;
    flex-flow: row nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  body.flowPdfToolRedesign .toolSwitch button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  body.flowPdfToolRedesign .viewerCard {
    width: 100% !important;
    height: auto !important;
    min-height: 55dvh !important;
    padding: 8px !important;
    border-radius: 18px !important;
  }

  .fileBox {
    padding: 14px 12px !important;
  }

  .uploadButton,
  .primary,
  .secondary,
  .danger {
    min-height: 48px !important;
  }

  .flowPdfCurrentFile {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .viewerToolbar {
    position: static !important;
    display: grid !important;
    gap: 8px !important;
  }

  .viewerToolbar .left,
  .viewerToolbar .right {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 7px !important;
  }

  .viewerToolbar .pageInfo {
    grid-column: 1 / -1;
    text-align: center;
  }

  .quickDock {
    right: 8px !important;
    bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    left: 8px !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    max-width: none !important;
    padding: 7px !important;
    scrollbar-width: none;
  }

  .quickDock button {
    flex: 0 0 auto !important;
    min-width: 76px !important;
  }

  .successOverlay,
  .confirmOverlay,
  .flowPdfEditorPromptOverlay,
  .flowPdfAssetPickerOverlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .successBox,
  .confirmBox,
  .flowPdfEditorPrompt,
  .flowPdfAssetPicker {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    border-radius: 24px 24px 0 0 !important;
  }

  .flowPdfReliableTwo,
  .flowPdfAdvancedTwo,
  .flowPdfAdvancedThree {
    grid-template-columns: 1fr !important;
  }

  .sfstStudio {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    gap: 8px !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .sfstPages {
    max-height: none !important;
    overflow: hidden !important;
    padding: 8px !important;
  }

  #sfstPageThumbs {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .sfstThumb {
    flex: 0 0 82px !important;
    width: 82px !important;
    margin: 0 !important;
    padding: 5px !important;
  }

  .sfstTools {
    display: flex !important;
    flex-flow: row nowrap !important;
    gap: 7px !important;
    overflow-x: auto !important;
    padding: 7px !important;
    scrollbar-width: none;
  }

  .sfstToolBtn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 92px !important;
    min-height: 44px !important;
  }

  .sfstRibbon {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .sfstRibbonGroup {
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
  }

  .sfstRibbonGroup::before {
    display: none !important;
  }

  .sfstCanvasShell {
    min-height: 52dvh !important;
    padding: 10px !important;
    overflow: auto !important;
  }

  /* Compress uses a full-screen mobile workspace. Keep the viewer itself
     scrollable after the general tool rules above have been applied. */
  body.flowpdfCompressMobile {
    width: 100% !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }

  body.flowpdfCompressMobile .layout {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow: hidden !important;
  }

  body.flowpdfCompressMobile .viewerCard {
    width: 100% !important;
    height: calc(100dvh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    min-height: 0 !important;
    padding: 10px 10px calc(112px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.flowpdfCompressMobile #workspaceArea {
    display: block !important;
    min-height: 100% !important;
    overflow: visible !important;
  }

  body.flowpdfCompressMobile .flowPdfCompressGrid {
    padding-bottom: calc(130px + env(safe-area-inset-bottom)) !important;
  }

  body.flowpdfCompressMobile .flowPdfCompressBottom {
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 350px) {
  .brand img.logo {
    width: 94px !important;
    max-width: 94px !important;
    flex-basis: 94px !important;
  }

  .flowPdfHeaderAttribution {
    padding-inline: 6px !important;
  }

  .flowPdfHeaderAttribution span {
    font-size: 0 !important;
  }

  .flowPdfHeaderAttribution span::after {
    content: "by";
    font-size: 9px;
  }
}

@media (max-width: 460px) {
  .flowPdfPopularGrid,
  .flowPdfCategoryGrid,
  .flowPdfDrawerGrid,
  .flowPdfReliablePageGrid,
  .flowPdfScanGrid,
  .flowPdfAdvancedGrid {
    grid-template-columns: 1fr !important;
  }

  .flowPdfToolCard {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 11px;
    min-height: 0;
  }

  .flowPdfToolIcon {
    grid-row: 1 / 3;
    width: 42px;
    height: 42px;
  }

  .flowPdfToolTitleRow {
    align-self: end;
    margin-top: 0;
  }

  .flowPdfToolCard strong {
    font-size: 14px;
  }

  .flowPdfToolCard p {
    display: block !important;
    grid-column: 2;
    margin-top: 4px;
  }

  .flowPdfHomeFileBar {
    grid-template-columns: 1fr !important;
    text-align: center;
  }

  .flowPdfHomeFileIcon {
    margin: auto;
  }

  .flowPdfHomeFileCopy {
    text-align: center;
  }

  .flowPdfHomeFileCopy strong {
    white-space: normal;
  }
}
