/* Office on iPhone — Nov 23 2026.
   Loaded after the layout and before the messaging kit. Keep the existing native
   bars, keyboard bridge and theme tokens; this is the room needed by fingers,
   readable records, and forms above the keyboard. Desktop and print are unchanged. */
@media screen and (max-width: 900px) {
  /* 34px actions were still shared with desktop. A minimum keeps large buttons
     and native controls large while making the small actions usable by touch. */
  html body .btn,
  html body :is(.wh-chip, .wh-clear, .wh-done, .wh-on, .sd-chip, .apchip, .to-mb),
  html body :is(.kl-lv .lv, .cnt-nudge button, .wcam-seg button),
  html body :is(#shipset button.chip, .gx-flags button.chip) {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }
  html body :is(.btn.icon, #dclose, .pk-share, .sc-check) {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  html body :is(#content, #drawer, .wsheet, .cnt-sheet) .btn {
    max-width: 100%;
    min-height: 44px;
    height: auto;
    padding-block: 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
  }
  html body :is(#content, #drawer) .row:has(> .btn),
  html body :is(.gx-acts, .dfoot, .wsh-h, .wsh-f, .sc-sec > header) {
    flex-wrap: wrap;
  }
  html body .field .row > :is(input, select) { min-width: 0; }
  html body .kl-lv .lv { padding: 8px 12px; font-size: 14px; }
  html body .sc-line { flex-wrap: wrap; }
  html body .sc-ln { flex-basis: 150px; overflow-wrap: anywhere; }

  /* Neighbouring fields take the same touch height. Leave checkboxes, camera
     inputs and the small hidden selects inside custom controls alone. */
  html body :is(.field, .row, .toolbar, .wsh-b) > input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
  html body :is(.field, .row, .toolbar, .wsh-b) > select,
  html body :is(.cb-note, .pc-in, .sd-q, .mk-in, .fdrop, #pc-q, #wt-q, #al-sec, #al-name, #al-qty, #upd-rurl),
  html body .to-dn input {
    min-height: 44px;
  }

  /* The current layout already sets 16px form text in glow.css. Extend that
     guarantee to Classic and editable text, without disabling pinch zoom. */
  html:not(.pkl) body input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
  html:not(.pkl) body select,
  html:not(.pkl) body textarea,
  html body [contenteditable="true"] {
    font-size: 16px !important;
  }
  html body #login #pin { font-size: 28px !important; }

  /* Home Screen installs use a translucent status bar too. The original inset
     rule only covered Capacitor; Safari reports zero here when it owns the bar. */
  html:not(.native):not(.nbar) body .top {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--top) + env(safe-area-inset-top, 0px));
  }
  html body .content {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  /* Give the records space to read. Keep the established flowing card layout
     and small metadata chips, and let the important copy wrap naturally. */
  html.pkl body .gx-row .gx-who > b { font-size: 16px; line-height: 1.35; }
  html.pkl body .gx-row .gx-who > .sub,
  html.pkl body .gx-row .gx-items,
  html body :is(.cnt-t small, .cb-tx, .ans-b, .cnt-note, .sc-ln) {
    font-size: 14px;
    line-height: 1.45;
  }
  html body :is(.field > label, .wsh-b label) { font-size: 14px; line-height: 1.4; }
  html.pkl body .gx-stats small { font-size: 12px; }
  html.pkl body .gx-stats .card > span { font-size: 13px; line-height: 1.35; }
  html.pkl body .content .ship-work .card h3 { font-size: 12px; min-height: 0; line-height: 1.3; }

  /* office.js already measures the usable screen in --vvh/--vvt for Messages.
     Reuse it for forms too: the native app deliberately does not resize its
     web view for the keyboard. Subtracting --kb here would count it twice. */
  html body :is(.drawer, .wsheet, .pk-sheet) {
    top: var(--vvt, 0px);
    bottom: auto;
    height: var(--vvh, 100dvh);
  }
  html body .drawer .dhead,
  html body .drawer .dfoot { flex-shrink: 0; }
  html body .drawer .dbody {
    min-height: 0;
    overscroll-behavior-y: contain;
    scroll-padding-block: 16px;
  }
  html body .drawer .dhead { flex-wrap: wrap; }
  html body .drawer .dhead h2 { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
  html body .drawer #dactions { flex-wrap: wrap; }
  html body :is(.wsh-card, .pk-card, .cnt-sheet) {
    max-height: max(120px, calc(var(--vvh, 100dvh) - env(safe-area-inset-top, 0px) - 16px));
    overscroll-behavior-y: contain;
  }
  html body .pk-card {
    max-height: max(120px, calc(var(--vvh, 100dvh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px));
  }
  html body .cnt-sheet {
    bottom: max(0px, calc(100dvh - var(--vvt, 0px) - var(--vvh, 100dvh)));
  }
  html body .cnt-body { min-height: 0; overscroll-behavior-y: contain; }
  html body :is(.cnt-bar, .cnt-foot) { flex-shrink: 0; }
  html.kbd body .drawer .dfoot,
  html.kbd body .cnt-foot { padding-bottom: 12px; }
  html.kbd body .wsh-card { padding-bottom: 16px; }
  html.kbd body .pk-card {
    bottom: 8px;
    max-height: max(120px, calc(var(--vvh, 100dvh) - env(safe-area-inset-top, 0px) - 16px));
  }

  /* PIN sign-in must be scrollable on a short screen or with the number pad up. */
  html body #login {
    top: var(--vvt, 0px);
    bottom: auto;
    height: var(--vvh, 100dvh);
    overflow-y: auto;
    padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
    align-items: safe center;
  }
  html.kbd body #login { padding-block: 16px; }
}
