/* Shared narrow-screen refinements for the recipient preview and signing UI. */
@media (max-width: 640px) {
  html,
  body,
  main {
    max-width: 100%;
    overflow-x: hidden;
  }

  .view-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .view-tabs button {
    min-width: 0;
    width: 100%;
    padding-inline: 10px;
    white-space: normal;
  }

  .preview-zone {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .custody-rail,
  .device-frame.mobile {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
  }

  .custody-rail {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .device-frame.mobile iframe {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  header:has(#doc-title) {
    flex-wrap: wrap;
  }

  #doc-title {
    order: 3;
    flex: 1 1 100%;
    width: 100% !important;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #route-strip.has-steps {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    white-space: normal;
  }

  #route-strip .route-step {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  #route-strip .route-step span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
