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

@media (max-width: 800px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  .visitor-shell,
  .desk {
    width: 100% !important;
    max-width: 100% !important;
    height: var(--app-height, 100svh) !important;
    min-height: var(--app-height, 100svh) !important;
    overflow: hidden !important;
  }

  .chat-card {
    width: 100% !important;
    max-width: 100% !important;
    height: var(--app-height, 100svh) !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  .chat-card > header,
  .desk-chat > header {
    flex: 0 0 auto;
    min-width: 0;
  }

  .chat-head-copy,
  .chat-panel,
  .desk-chat,
  .start-panel,
  .messages,
  .composer-input {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .chat-panel,
  .desk-chat {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .messages,
  .conversation-list {
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .chat-panel form,
  .desk-chat form {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box !important;
    padding: 10px !important;
    background: #fff !important;
    position: relative;
    z-index: 4;
  }

  /* The agent app may run as an installed PWA; only it needs Home Indicator space. */
  .desk-chat form {
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .chat-panel form .composer-input,
  .desk-chat form .composer-input {
    flex: 1 1 auto;
    min-width: 0 !important;
  }

  .chat-panel form textarea,
  .desk-chat form textarea {
    display: block;
    width: 100% !important;
    min-height: 44px;
    max-height: 96px;
    margin: 0 !important;
    padding: 11px 42px 11px 12px !important;
    border-radius: 11px !important;
    line-height: 20px;
  }

  .chat-panel form > button,
  .desk-chat form > button {
    flex: 0 0 auto !important;
    align-self: stretch;
    min-width: 48px;
    min-height: 44px;
    margin: 0 !important;
    border-radius: 11px !important;
    padding: 0 14px !important;
  }

  .composer-input .emoji-btn {
    right: 7px !important;
    bottom: 7px !important;
  }

  textarea,
  input,
  select {
    max-width: 100%;
  }

  /* iOS Safari zooms the whole page when a focused form control is below 16px. */
  .chat-panel textarea,
  .desk-chat textarea,
  .start-panel input,
  .login-card input,
  .modal input,
  .modal textarea,
  .modal select {
    font-size: 16px !important;
  }

  #transferModal {
    position: fixed !important;
    inset: auto 0 auto 0 !important;
    top: var(--app-offset-top, 0px) !important;
    width: 100% !important;
    height: var(--app-height, 100svh) !important;
    z-index: 120 !important;
    align-items: end !important;
    box-sizing: border-box !important;
    padding: 12px 12px calc(28px + env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
  }

  #transferModal > div {
    width: 100% !important;
    max-width: 520px !important;
    max-height: calc(var(--app-height, 100svh) - 56px - env(safe-area-inset-bottom));
    margin: 0 !important;
    overflow-y: auto;
    border-radius: 18px !important;
    padding: 24px 18px 18px !important;
    box-shadow: 0 18px 50px #102a2250 !important;
    animation: mobile-sheet-in .2s ease-out;
  }

  #transferModal select,
  #transferModal input,
  #transferModal button {
    width: 100%;
  }

  @keyframes mobile-sheet-in {
    from { opacity: .7; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
}
