/* Keep the order editor independent of the ERP's generic mobile-card table. */
@media (max-width: 860px) {
  .commerce-admin.is-mobile-order-detail-open > .commerce-print-queue-strip {
    display: none;
  }
}

@media (max-width: 700px) {
  .commerce-admin .commerce-order-toolbar > label:not(.commerce-order-search) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }
  .commerce-admin .commerce-order-toolbar > label:not(.commerce-order-search) select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #c1d3da;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
    font-size: 16px;
  }
  .commerce-review-backdrop {
    top: var(--app-visible-viewport-top, 0px);
    bottom: auto;
    height: var(--app-visible-viewport-height, 100dvh);
    box-sizing: border-box;
    touch-action: pan-y !important;
  }
  .commerce-review-workbench .commerce-review-header > div:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .commerce-review-workbench .commerce-review-header-actions .icon-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  .commerce-review-backdrop .commerce-review-workbench > .commerce-review-table-wrap {
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
  }
  .commerce-review-workbench .commerce-review-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .commerce-review-workbench .commerce-review-table tbody {
    display: grid !important;
    gap: 8px;
    padding: 8px;
  }
  .commerce-review-workbench .commerce-review-table tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(116px, .45fr);
    width: auto !important;
    margin: 0;
    padding: 10px;
  }
  .commerce-review-workbench .commerce-review-table td:nth-child(n) {
    display: block !important;
    width: auto !important;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
    grid-template-columns: none !important;
    gap: 0 !important;
  }
  .commerce-review-workbench .commerce-review-table td:first-child::before {
    display: none !important;
  }
  .commerce-review-workbench .commerce-review-table td:first-child strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .commerce-review-workbench .commerce-review-table td:nth-child(3) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 30px !important;
    align-content: start;
    gap: 4px !important;
  }
  .commerce-review-workbench .commerce-review-table td:nth-child(3)::before,
  .commerce-review-workbench .commerce-review-table td:nth-child(3) > small {
    grid-column: 1 / -1;
  }
  .commerce-review-workbench .commerce-review-quantity {
    box-sizing: border-box;
    min-width: 0;
    min-height: 44px;
  }
  .commerce-review-workbench .commerce-review-quantity input,
  .commerce-review-workbench .commerce-review-search input,
  .commerce-review-workbench .commerce-review-footer input:not([type="checkbox"]) {
    font-size: 16px;
  }
  .commerce-review-workbench .commerce-review-footer > .order-example-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px;
    align-items: end;
  }
  .commerce-review-workbench .commerce-review-footer .order-example-pair > label {
    min-width: 0;
  }
  .commerce-review-workbench .commerce-review-footer :is(.small-button, .primary-button) {
    min-height: 44px;
  }
  /* visualViewport can shrink while Safari keeps the layout viewport tall. */
  .app-mobile-keyboard-open .commerce-review-backdrop .commerce-review-workbench {
    display: block;
    box-sizing: border-box;
    padding-bottom: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .app-mobile-keyboard-open .commerce-review-workbench > .commerce-review-table-wrap {
    overflow: visible;
  }
  .app-mobile-keyboard-open .commerce-review-workbench .commerce-review-footer {
    position: static;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
  .app-mobile-keyboard-open .commerce-review-workbench .order-example-pair > label {
    display: grid;
  }
}

/* When the keyboard or landscape leaves little height, scroll the whole editor. */
@media (max-width: 700px) and (max-height: 620px) {
  .commerce-review-backdrop .commerce-review-workbench {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .commerce-review-backdrop .commerce-review-workbench > .commerce-review-table-wrap {
    overflow: visible;
  }
  .commerce-review-workbench .commerce-review-footer {
    position: static;
  }
  .commerce-review-workbench .commerce-review-footer .order-example-pair > label {
    display: grid;
  }
}
