/* Client-only phone layout. Shared workflows and desktop styles stay unchanged. */
@media (max-width: 760px) {
  body.is-client-workspace .sr-create-form input:not([type="checkbox"]):not([type="radio"]),
  body.is-client-workspace .sr-create-form select,
  body.is-client-workspace .sr-create-form textarea,
  body.is-client-workspace .sr-reply-form input,
  body.is-client-workspace .sr-reply-form textarea,
  body.is-client-workspace .sr-history-search input,
  body.is-client-workspace .commerce-core-grid > label:not(.commerce-imo-field) > input:not([type="checkbox"]),
  body.is-client-workspace .commerce-core-grid > label:not(.commerce-imo-field) > select,
  body.is-client-workspace .commerce-detail-grid input:not([type="checkbox"]),
  body.is-client-workspace .commerce-detail-grid select,
  body.is-client-workspace .commerce-request-modal input:not([type="radio"]):not([type="checkbox"]),
  body.is-client-workspace .commerce-request-modal textarea {
    min-width: 0;
    max-width: 100%;
    min-height: var(--ds-control-height-md);
    font-size: 16px;
    line-height: var(--ds-line-height-base);
  }

  body.is-client-workspace .sr-field,
  body.is-client-workspace .sr-reply-form label,
  body.is-client-workspace .sr-repeatable-row label,
  body.is-client-workspace .sr-si-container-row label,
  body.is-client-workspace .commerce-core-grid > label:not(.commerce-imo-field),
  body.is-client-workspace .commerce-detail-grid > label,
  body.is-client-workspace .commerce-request-modal form > label,
  body.is-client-workspace .commerce-request-modal .commerce-party-grid label,
  body.is-client-workspace .commerce-request-modal .commerce-routing-grid legend {
    min-width: 0;
    font-size: var(--ds-font-size-md);
    line-height: var(--ds-line-height-base);
  }

  body.is-client-workspace .sr-field small,
  body.is-client-workspace .sr-form-section small,
  body.is-client-workspace .sr-file-control > span,
  body.is-client-workspace .sr-si-party > header small,
  body.is-client-workspace .sr-detail-summary dt,
  body.is-client-workspace .sr-request-data dt,
  body.is-client-workspace .sr-message header small {
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-base);
  }

  body.is-client-workspace .sr-detail-summary dd,
  body.is-client-workspace .sr-request-data dd,
  body.is-client-workspace .sr-message-files > div {
    font-size: var(--ds-font-size-md);
  }

  body.is-client-workspace .sr-drawer-panel,
  body.is-client-workspace .sr-drawer--si .sr-drawer-panel--si[data-si-step] {
    height: 100%;
    height: 100dvh;
  }

  body.is-client-workspace .sr-drawer-panel > header,
  body.is-client-workspace .sr-drawer--si .sr-drawer-panel--si > header {
    gap: var(--ds-space-2);
    padding: calc(var(--ds-space-3) + env(safe-area-inset-top, 0px)) var(--ds-space-3) var(--ds-space-3);
  }

  body.is-client-workspace .sr-drawer-panel > header > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body.is-client-workspace .sr-drawer-body,
  body.is-client-workspace .sr-create-form--si .sr-form-grid {
    overscroll-behavior-y: contain;
    scroll-padding-block: var(--ds-space-4) 120px;
  }

  body.is-client-workspace .sr-form-grid,
  body.is-client-workspace .sr-create-form--si .sr-form-grid {
    padding: var(--ds-space-3);
  }

  body.is-client-workspace .sr-si-step-content,
  body.is-client-workspace .sr-si-party,
  body.is-client-workspace .sr-create-form--si .sr-si-container-row {
    min-width: 0;
    padding: var(--ds-space-3);
    gap: var(--ds-space-3);
  }

  body.is-client-workspace .sr-si-step[data-si-step="1"] .sr-si-step-content,
  body.is-client-workspace .sr-si-step[data-si-step="4"] .sr-si-step-content {
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.is-client-workspace .sr-si-party-fields {
    gap: var(--ds-space-2);
  }

  body.is-client-workspace .sr-create-form--si .sr-field,
  body.is-client-workspace .sr-create-form--si .sr-si-container-row label {
    gap: var(--ds-space-1);
  }

  body.is-client-workspace .sr-create-form--si textarea {
    height: 72px;
    min-height: 72px;
    overflow: auto;
    resize: vertical;
  }

  body.is-client-workspace .sr-si-container-row {
    grid-template-columns: minmax(0, 1fr);
  }

  body.is-client-workspace .sr-si-container-row > button {
    grid-column: 1;
    justify-self: end;
  }

  body.is-client-workspace .sr-repeatable-row {
    grid-template-columns: minmax(0, 1fr) var(--ds-control-height-md);
  }

  body.is-client-workspace .sr-form-actions,
  body.is-client-workspace .sr-create-form--si .sr-form-actions {
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-3) calc(var(--ds-space-3) + env(safe-area-inset-bottom, 0px));
  }

  body.is-client-workspace .sr-create-form button,
  body.is-client-workspace .sr-reply-form button,
  body.is-client-workspace .sr-filter-tabs button,
  body.is-client-workspace .sr-mobile-back,
  body.is-client-workspace .sr-si-detail-actions button,
  body.is-client-workspace .sr-chat-head-actions .chat-export-action {
    min-height: var(--ds-control-height-md);
    font-size: var(--ds-font-size-md);
  }

  body.is-client-workspace .sr-drawer-panel > header .close,
  body.is-client-workspace .sr-si-help-dialog button,
  body.is-client-workspace .sr-repeatable-row button,
  body.is-client-workspace .sr-si-container-row > button {
    flex: 0 0 var(--ds-control-height-md);
    width: var(--ds-control-height-md);
    min-width: var(--ds-control-height-md);
    height: var(--ds-control-height-md);
    min-height: var(--ds-control-height-md);
  }

  body.is-client-workspace .sr-create-form .sr-si-info {
    flex: 0 0 auto;
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    margin-left: var(--ds-space-1);
    font-size: var(--ds-font-size-md);
    line-height: 1;
    vertical-align: middle;
  }

  body.is-client-workspace .sr-si-confirmation {
    padding: var(--ds-space-3);
    font-size: var(--ds-font-size-md);
  }

  body.is-client-workspace .sr-si-confirmation input {
    flex-basis: 22px;
    width: 22px;
    min-height: 22px;
    height: 22px;
  }

  body.is-client-workspace .sr-si-help-dialog {
    top: calc(var(--ds-space-2) + env(safe-area-inset-top, 0px));
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow: auto;
    overscroll-behavior-y: contain;
  }

  body.is-client-workspace .sr-si-help-dialog > div {
    grid-template-columns: 24px minmax(0, 1fr) var(--ds-control-height-md);
    gap: var(--ds-space-2);
    padding: var(--ds-space-3);
  }

  body.is-client-workspace .sr-si-help-dialog > div > span {
    width: 24px;
    height: 24px;
  }

  body.is-client-workspace .sr-si-help-dialog p {
    font-size: var(--ds-font-size-md);
    overflow-wrap: anywhere;
  }

  body.is-client-workspace .sr-section-head,
  body.is-client-workspace .sr-message header {
    flex-wrap: wrap;
    gap: var(--ds-space-2);
  }

  body.is-client-workspace .sr-message,
  body.is-client-workspace .sr-message-list,
  body.is-client-workspace .sr-reply-form,
  body.is-client-workspace .sr-message-files,
  body.is-client-workspace .sr-message-files > div,
  body.is-client-workspace .sr-message-files > div > span {
    min-width: 0;
  }

  body.is-client-workspace .sr-message p,
  body.is-client-workspace .sr-message header strong,
  body.is-client-workspace .sr-message-files > div > span {
    overflow-wrap: anywhere;
  }

  body.is-client-workspace .sr-message-files > div {
    flex-wrap: wrap;
    align-items: center;
  }

  body.is-client-workspace .sr-message-files a {
    display: inline-flex;
    align-items: center;
    min-height: var(--ds-control-height-md);
    padding-inline: var(--ds-space-2);
  }

  body.is-client-workspace .commerce-request-modal {
    top: calc(var(--ds-space-2) + env(safe-area-inset-top, 0px));
    max-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    overflow: auto;
    overscroll-behavior-y: contain;
  }

  body.is-client-workspace .commerce-request-modal .commerce-segmented label {
    position: relative;
    min-width: 0;
  }

  body.is-client-workspace .commerce-request-modal .commerce-segmented input[type="radio"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    min-width: 0;
    height: 1px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
  }

  body.is-client-workspace .commerce-request-modal .commerce-segmented span {
    min-height: var(--ds-control-height-md);
    font-size: var(--ds-font-size-md);
  }

  body.is-client-workspace .commerce-request-modal .commerce-segmented input[type="radio"]:focus-visible + span {
    outline: 2px solid var(--ds-color-link);
    outline-offset: 2px;
    box-shadow: var(--ds-focus-ring);
  }

  body.is-client-workspace .ai-sheet {
    right: calc(var(--ds-space-2) + env(safe-area-inset-right, 0px));
    bottom: calc(var(--ds-space-2) + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    height: min(620px, calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    height: min(620px, calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    overflow: auto;
    overscroll-behavior-y: contain;
  }

  body.is-client-workspace .ai-sheet > header,
  body.is-client-workspace .ai-sheet .ai-context-note,
  body.is-client-workspace .ai-sheet .suggestions,
  body.is-client-workspace .ai-sheet #aiForm {
    flex-shrink: 0;
  }

  body.is-client-workspace .ai-sheet > header {
    padding: var(--ds-space-3);
  }

  body.is-client-workspace .ai-sheet .chat {
    min-height: 0;
    padding: var(--ds-space-3);
    overscroll-behavior-y: contain;
  }

  body.is-client-workspace .ai-sheet .bubble {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body.is-client-workspace .ai-sheet .ai-context-note {
    padding-inline: var(--ds-space-3);
    font-size: var(--ds-font-size-sm);
  }

  body.is-client-workspace .ai-sheet .suggestions {
    padding: var(--ds-space-2) var(--ds-space-3);
  }

  body.is-client-workspace .ai-sheet .suggestions button,
  body.is-client-workspace .ai-sheet .bubble button {
    min-height: var(--ds-control-height-md);
    font-size: var(--ds-font-size-md);
  }

  body.is-client-workspace .ai-sheet .close,
  body.is-client-workspace .ai-sheet #aiForm button {
    flex: 0 0 var(--ds-control-height-md);
    width: var(--ds-control-height-md);
    min-height: var(--ds-control-height-md);
    height: var(--ds-control-height-md);
  }

  body.is-client-workspace .ai-sheet #aiForm {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3);
    background: var(--ds-color-surface);
  }

  body.is-client-workspace .ai-sheet #aiForm textarea {
    min-width: 0;
    min-height: var(--ds-control-height-lg);
    max-height: 160px;
    font-size: 16px;
  }
}

@media (max-width: 760px) and (max-height: 560px) {
  /* On a short screen the sheet itself can scroll; chat never collapses to zero. */
  body.is-client-workspace .ai-sheet .chat {
    flex: 1 0 120px;
  }
}
